Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 68,438 of 68,980    |
|    Herbert Kleebauer to All    |
|    Re: Replace line in a txt file with miss    |
|    11 Jan 24 21:25:44    |
   
   From: klee@unibwm.de   
      
   On 11.01.2024 20:03, Zaidy036 wrote:   
      
   > When I must frequently test a batch as I develop it I add an icon to the   
   > desktop. In this case it is set to run as administrator and produces the   
   > same results as running from the actual file location.   
      
   But in this case you should really open a CMD window, CD to the directory   
   with the batch and start the batch with batchname.bat because then the   
   CMD window remains open after the batch has finished.   
      
      
   > I ran three tests and it appears that {IF "%B"==" "} is the problem   
   > because the first two tests crash.   
      
   I don't think your batch crashes, but it just ends without   
   finding an SSID without a name. Insert a   
      
   echo start batch > F:\_NW-N.txt   
      
   at the beginning of the batch and a   
      
   echo end batch >> F:\_NW-N.txt   
      
   at the end of the batch to make sure the batch doesn't crash.   
      
      
      
   > Note that the last shows %B is " " is   
   > the value when the name does not exist.   
      
   SSID 6 : ResidentsB   
   SSID 7 :   
      
   In my input file I have no space after the colon in "SSID 7 :".   
   If in your input file is a space, then you have to use   
   IF "%%B"==" "   
      
   >   
   > FOR /F "USEBACKQ TOKENS=1,2 DELIMS=:" %%A IN ("F:\_NW-B.txt") DO (   
   > IF "%B"==" " ECHO %%A >> F:\_NW-N.txt)   
   >   
   > FOR /F "USEBACKQ TOKENS=1,2 DELIMS=:" %%A IN ("F:\_NW-B.txt") DO (IF   
   > "%B"==" " ECHO "%%A" "%%B")   
      
   Is this line wrap done by your news reader or is it done this   
   way in your batch file (then you have to move the "IF" on the next line).   
      
      
      
   > FOR /F "USEBACKQ TOKENS=1,2 DELIMS=:" %%A IN ("F:\_NW-B.txt") DO (ECHO   
   > "%%A" "%%B")   
   >   
   > If you are willing run the last cmd against your input file and see if   
   > your "%B" is "" or " ". If "" could you add spaces where the names are   
   > blank and retest?   
      
   If I insert a space after "SSID 7 :" and use IF "%%B"==" " then the   
   batch also works. _NW-N.txt is created correctly.   
      
   --- 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