home bbs files messages ]

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 67,839 of 68,980   
   LangerTom to All   
   Re: Problem with file trimming in Batch   
   30 Nov 21 19:24:11   
   
   From: hobby.tl@langer-online.net.invalid   
      
   I believe that your command   
   SET ZC=1   
   is working fine, but checking its result with   
   echo === %ZC%   
   is going wrong because both lines are placed between round brackets.   
   CMD.EXE is reading all code betwwen round brackets at once and is   
   resolving variables like %ZC% during code reading. At this time your   
   command   
   set ZC=1   
   did not take place yet.   
   To avoid this switch on DELAYEDEXPANSION and note variables like this; !ZC!   
      
   The following code should work (not tested):   
      
   HTH Thomas   
      
   By the way: working on html with batch is very hard stuff because html   
   code contains many poison characters like <>?*/"&   
      
      
      
   @echo.   
   SETLOCAL ENABLEDELAYEDEXPANSION   
   @if not exist zzz\nul mkdir zzz   
   @echo 1111   
      
   @SET ZC=0   
   @echo. Start >  ZZZ\ORIG.HTM   
   @FOR /F "eol=; tokens=*" %%J IN (PRUNE.DAT) DO @(   
      @echo Comment line='%%J'  ZC=!ZC!   
      if [!ZC!] == [1] (   
        echo       '%%J'  >>  ZZZ\ORIG.HTM   
        )   
      if [%%J] == [####] (   
        set ZC=1   
        echo === !ZC!   
        )   
      @echo ++   
      )   
      
   @echo 9999   
      
   @echo. Ended >>  ZZZ\ORIG.HTM   
   @echo.   
      
   type ZZZ\ORIG.HTM   
      
   @echo PRUNE.BAT ends.   
      
      
      
      
      
   Am 30.11.2021 um 15:03 schrieb John Stockton:   
   > I want to copy an HTML page file to another file, omitting both the   
   heading+introduction and the tailpiece.  For test I use a line of four hashes   
   as separator, and a test file :   
   >   
   > head   
   > ####   
   > want   
   > ####   
   > tail   
   >   
   > My non-working test code is in :   
   >   
   > @echo PRUNE.BAT JRS 2021-11-30+    ???   
   >   
   > @echo.   
   > @if not exist zzz\nul mkdir zzz   
   > @echo 1111   
   >   
   > @SET ZC=0   
   > @echo. Start >  ZZZ\ORIG.HTM   
   > @FOR /F "eol=; tokens=*" %%J IN (PRUNE.DAT) DO @(   
   >    @echo Comment line='%%J'  ZC=%ZC%   
   >    if [%ZC%] == [1] (   
   >      echo       '%%J'  >>  ZZZ\ORIG.HTM   
   >      )   
   >    if [%%J] == [####] (   
   >      set ZC=1   
   >      echo === %ZC%   
   >      )   
   >    @echo ++   
   >    )   
   >   
   > @echo 9999   
   >   
   > @echo. Ended >>  ZZZ\ORIG.HTM   
   > @echo.   
   >   
   > type ZZZ\ORIG.HTM   
   >   
   > @echo PRUNE.BAT ends.   
   >   
   > The apparent problem is that the line     set ZC=1    has no effect, so that   
   the wanted part is not copied. ( I intend to change it to    set /A   
   ZC=1+%ZC%       which should mean that the tail part is not copied).    
   Subsequently I may use a line       
      as an invisible separator.   
   >   
   > What's wrong?   
   >   
   >   
      
   --- 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