Delete all files while maintaining the directory structure

Given the directory structure c: \ a \ b \ c \ d \ - which DOS command will delete all files contained in c: \ a, along with any files in the b, c and d subdirectories? We do not want to delete directories - just files.

+6
source share
3 answers

The DEL command only deletes files, not directories, so the following command will execute upon your request:

 DEL /SC:\a 

You need to use RMDIR to delete directories.

+8
source

Using:

 del *.* /s /q 

Verify that the directories still exist:

 tree 
+3
source
 @del /S /Q /F a\* >nul @for /d %%i in (a\*) do @rmdir /s /q "%%i" 
0
source

All Articles