Delete all files while maintaining directory structure

Marcus Leon picture Marcus Leon · Mar 26, 2013 · Viewed 19.3k times · Source

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

Answer

RB. picture RB. · Mar 26, 2013

The DEL command only deletes files, not directories, so the following command will do as you asked:

DEL /S C:\a

You need to use RMDIR to remove directories.