Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch    |    Fun with MS-DOS batch files    |    42,547 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 40,583 of 42,547    |
|    foxidrive to matthew.eve@gmail.com    |
|    Re: open newest file & then replace + wi    |
|    22 Nov 12 09:48:33    |
   
   From: not@this.address.invalid   
      
   On 22/11/2012 03:32, matthew.eve@gmail.com wrote:   
   > I am looking for some help. I am in the process of writing a batch file that   
   will open the newest file in the directory:   
      
   When you say open the file, I assume you want to launch the associated app to   
   open the file.   
      
   start "" "%folder%\%newest%"   
      
      
   > @echo off   
   > set folder=C:\directory\   
   > for /f "tokens=1 delims=" %%a in ('dir /b /o:d "%folder%"') do set newest=%%a   
   > if not "%newest%"=="" echo Newest file is "%newest%"   
   > if not "%newest%"=="" echo Full path: "%folder%\%newest%"   
   > Exit   
   >   
   > the second part I need is to have batch file look for any +'s in the file   
   and replace with 0's   
   >   
   > example of current line 01G030160|G04C|G0501|G0601|G07A|G0801|G09+00032.00|   
   > final result 01G030160|G04C|G0501|G0601|G07A|G0801|G09000032.00|   
   >   
   > Then save the same in the same directory but with different name.   
      
      
   This script will replace + with 0   
   The input file is filein.txt in the current directory and it writes to   
   fileout.txt   
      
      
   @set @JScript=1/*   
   @echo off   
   setlocal   
      
   cscript //nologo //E:JScript "%~f0"   
   goto :eof   
      
   */   
      
   // JScript   
   //   
   var ForReading= 1   
   var ForWriting = 2   
      
   var fso = new ActiveXObject("Scripting.FileSystemObject");   
      
   // paths must have doubled backslashes if used eg:   
   // var input = fso.OpenTextFile("c:\\temp\\filein.txt", ForReading)   
   // var output = fso.OpenTextFile("c:\\temp\\fileout.txt", ForWriting, true)   
      
   var input = fso.OpenTextFile("filein.txt", ForReading)   
   var output = fso.OpenTextFile("fileout.txt", ForWriting, true)   
      
      
   var data = input.Readall()   
   data = data.replace(/\+/g , "0")   
      
      
   output.Write(data)   
      
   input.Close()   
   output.Close()   
      
      
   --   
   foxi   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca