Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force my batch file to hide the cmd window and say "yes"? [closed]

Okay so I am trying to make a simple BAT file that deletes files in multiple folders. Now this is what I have so far. I would like it so it deletes all files and folders in the Temp directory but not folders in the data directory... I would also like it to say yes to the prompts. How do I do this???

@ECHO OFF
DEL "C:\ProgramData\TVersity\Media Server\data\*.*" 
DEL "%LOCALAPPDATA%\Temp\*.*"

I am planning on adding in more directories into this BAT file so please if you can respond with "how to commands"... Because I would like to know how to specify whether to delete all folders and files or just files.

Also how to automate the "yes" to all prompts.

like image 542
Radical924 Avatar asked Jan 17 '26 21:01

Radical924


1 Answers

del /s /q c:\somedirectory\*.*

should take care of deleting all files recursively without deleting the directories, in "quiet" mode, which doesn't give you the prompt.

To delete an entire directory and all of its files and subdirectories, you can use rd with the same flags:

rd /s /q c:\somedirectory

http://technet.microsoft.com/en-us/library/cc771049.aspx

like image 116
Joe Enos Avatar answered Jan 19 '26 11:01

Joe Enos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!