home bbs files messages ]

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 41,030 of 42,547   
   Todd Vargo to Batchman   
   Re: delete files without prompt   
   01 Dec 14 01:45:04   
   
   From: tlvargo@sbcglobal.netz   
      
   On 11/30/2014 6:53 PM, Batchman wrote:   
   > marc28@gmail.com wrote:   
   >   
   >>>> I have put the following command in a batch file   
   >>>>   
   >>>> del *.*   
   >>>   
   >   
   > Another method to delete all files without prompt is to CD into the correct   
   > folder and then...   
   >   
   > FOR %%f IN (*.*) DO DEL %%f   
   >   
   > This loop uses the DEL command to delete each file individually.   
   >   
   > WARNING you must ensure that your batch file uses a CD (Change Directory)   
   > command to make the default directory the correct one before using the FOR   
   > loop line above!   
   >   
   > Batchman   
      
   Brilliant! So if your batch file uses a CD to a directory that does not   
   exist, all files in whatever directory happens to be current will be   
   deleted without question.   
      
   I advocate that if you know path to the directory that you want to make   
   current, then either place that path in the DEL or in the FOR command.   
      
   DEL c:\path-to\*.*   
      
   or   
      
   for %%f in (c:\path-to\*.*) do del %%f   
      
   Wildcard deletes based on whatever directory is current is a sure fire   
   path to disaster. You have been warned.   
      
   --   
   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