Windows – Delete all files and directories from Command Prompt

command linewindows 8

I have the following situation. I got a Temp folder which gets filled with all kinds of files and directories. I want/need to clean it regularly, but I can't figure out a command or set of MS-DOS command to do so.
Command called erase deletes all the files, so no problem there, but the directories is the thing I'm struggling with. I know some of you might suggest deleting the Temp directory and then creating it, which is NOT an option for me unfortunately, since I MUST keep it intact, since doing messes up things on my system.

Any ideas, good people? 🙂

Best Answer

In a MS-DOS system use deltree.

DELTREE [/Y] directory\*.*

From a cmd windows in the latest versions you can use rd.exe or rmdir.exe

rd directory/* /s

or

rmdir directory/* /s

Related Question