How to correctly remove all files from a directory in Windows7?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
PiotrMP006
Posts: 31
Joined: 08 Sep 2017 06:10

How to correctly remove all files from a directory in Windows7?

#1 Post by PiotrMP006 » 04 Oct 2017 02:18

How to correctly remove all files from a directory in Windows7?

Without *

Code: Select all

del C:\Test

With *

Code: Select all

del C:\Test\*

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: How to correctly remove all files from a directory in Windows7?

#2 Post by aGerman » 04 Oct 2017 10:55

You might want to use option /F to remove read-only files, too. Also use /Q to suppress the confirmation message if you want to use the asterisk as wildcard. If you want to remove files in subdirectories you have to use option /S additionally.
Note that DEL deletes files only. If you want to remove subdirectories you would need RD (preferably with options /S and /Q).
FWIW We have a Command Index on DosTips where you could have read the usage of the commands. Also executing del /? and rd /? gives you the same informations.

Steffen

Post Reply