Windows – How to delete all files/subfolders in a given folder via the command prompt

command linewindowswindows 7

I would like to delete all files and subfolders in a batch file in Windows 7 and keep the top folder. Basically emptying the folder. What's the command line instruction for that?

Best Answer

You can do this using del and the /S flag (to tell it to remove all files from all subdirectories):

del /S C:\Path\to\directory\*