DOS - How to delete all files and subdirectories in a directory. - TechRepublic
Question
December 4, 2007 at 12:27 PM
charliespencer

DOS – How to delete all files and subdirectories in a directory.

by charliespencer . Updated 14 years, 5 months ago

Okay, not really DOS, but from a Windows Server command prompt.

I’m trying to remember how to delete all files, subdirectories, and subdirectory contents from a specific directory from a command prompt. We have a “catch all” folder for short-term file sharing and I want to delete the contents nightly, but not the folder itself, using a scheduled command procedure.

Unfortunately I’m the poster boy for the American CRS Foundation and have forgotten how to do this. RMDIR won’t take a wildcard. DELTREE is apparently dead and gone. I’m currently using

DEL /F /Q /S C:\Directory\*.*

but that leaves the empty subdirs in place.

Help. Thanks.

This discussion is locked

All Comments