How to delete all files in a directory using a package?

I have a very simple request. I have a folder "x" on my desktop (Windows 7), and I want to write a batch program to delete all the files in it. (all extensions) This is what I came up with:

cd c:\users\admin\desktop\x\ del *.* 

but when I open it, the console still asks for human input (Y / N). What can I do to get around this?

+6
source share
3 answers

Always use an explicit path so that the error does not delete the current folder, no matter what it might be at that time.

All visible files silently

 del "c:\users\admin\desktop\x\*.*?" 

All visible files silently using / q

 del /q "c:\users\admin\desktop\x\*.*" 

All visible files, including subdirectories, silently

 del /s /q "c:\users\admin\desktop\x\*.*" 

enter del /? for full details.

+20
source
 del /q *.* 

See del /? Assuming the user has the appropriate permissions.

0
source

It is dangerous, but

 del *?* 

or

 del ?*? 

should be removed as necessary.

0
source

Source: https://habr.com/ru/post/949651/


All Articles