Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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? :)

share|improve this question
10  
Did you actually mean MS-DOS or did you mean Command Prompt within Windows? –  Graham Wager Jan 31 '13 at 18:42
    
Yessir, I very much did. –  adamas Feb 1 '13 at 12:18

2 Answers 2

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

share|improve this answer
1  
Well, DELTREE is out of the question, since we're talking command promt in Winodws 8 basically. As for rd and rmdir, for some reason none of them does what I need. I mean, if I do rm/rmdir c:\q* /s it 1) asks for a confirmation, which it should not because of /s 2) does nothing when I confirm it. Weird... Any other ideas, good people of SuperUser :) –  adamas Feb 1 '13 at 12:16

If you don't want to have it asking you for confirmation you need also the /Q switch

I have a batch file that does the following:

rmdir E:\Documents /s /q

I wanted it to delete the contents of the Documents folder but instead this command deletes the whole folder. I tried E:\Documents* but to no avail.

So what I ended up doing was:

rmdir E:\Documents\*.* /s /q
mkdir E:\Documents
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.