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 66,994 of 68,980   
   Todd Vargo to Docfxit   
   Re: Trying to delete all files with cert   
   31 Jul 17 00:12:31   
   
   From: tlvargo@sbcglobal.netz   
      
   On 7/29/2017 9:19 PM, Docfxit wrote:   
   > I would like to delete all *.log files from the root of C: through all   
   folders.   
   > This code isn't deleting all *.log files.   
   >   
   > del deleteTmp.bat   
   >      >  file.txt echo/*.tmp   
   >      >> file.txt echo/*._mp   
   >      >> file.txt echo/*.log   
   >   
   > for /f "delims=" %%a in (file.txt) do >>DeleteTmp.bat echo del /F /S "c:\%%a   
   >> Delete.log"   
   > Call DeleteTmp.bat   
   > cmd   
   >   
   > It also isn't writing out the Delete.log file.   
   >   
   > Can anyone help me figure out why?   
   >   
   > Thanks,   
   >   
   > Docfxit   
   >   
      
   If you insert a PAUSE before the CALL line to verify the contents of   
   DeleteTmp.bat, you would find that its contents are not what you expect.   
      
   I get the following contents in DeleteTmp.bat   
      
   del /F /S "c:\*.tmp >> Delete.log"   
   del /F /S "c:\*._mp >> Delete.log"   
   del /F /S "c:\*.log >> Delete.log"   
      
   Its not deleting the files and not putting anything in Delete.log   
   because everything in the quotes in DeleteTmp.bat are being treated as a   
   complete fimename. Also the Delete.log is a poorly chosen name as it   
   falls into the scope of *.log which can not be deleted because the file   
   is in use.   
      
   To solve this problem, remove both dbl-quotes and properly escape the   
   redirection with ^>^>.   
      
   Personally, I would reduce the entire thing down to just one line and   
   eliminate all of the temp files. KISS.   
      
   del /F /S c:\*.tmp c:\*._mp c:\*.log > Delete.log 2>nul   
      
   --   
   Todd Vargo   
   (Post questions to group only. Remove "z" to email personal messages)   
      
   --- 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