Supressing Prompts In Batch Files While Deleting All Files

Contributor Icon Contributed by AlexTheBeast Date Icon December 6, 2003  
Tag Icon Tagged: Batch file programming

Successful batch files cannot be slowed down with a bunch of user prompts. This little recipe will show you how to supress prompts in batch files.


Commands such as deleting all files can complicate batch files because the system prompts for confirmation. For example…

del *.* replies with *.*, Are you sure (Y/N)?

Man, that’ll slow up a batch file.

By using echo this will automatically reply for you:

echo y| del *.*

To supress the “File Not Found” error when trying to delete files from an empty directory, use this code instead:

if exist *.* echo y| del *.*

Previous recipe | Next recipe |
 

Viewing 1 Comment

close Reblog this comment
blog comments powered by Disqus