Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the windows equivalent of rm -r [directory-name]?

share|improve this question
up vote 223 down vote accepted

deltree if I remember my DOS.

It seems it's been updated... this is what you want:


This removes the directory C:\test, with prompts :

rmdir c:\test /s

This does the same, without prompts :

rmdir c:\test /s /q

Regarding the sudo part of your question, if you need more priviliges, you can first open a new shell as another user account using the runas command, like this:

runas /user:Administrator cmd
rmdir c:\test /s /q
share|improve this answer
hmm . . . doesn't work for me. – Eric Wilson Aug 23 '10 at 19:32
@FarmBoy, apologies, it would seem my memories go far too far back. I've updated the answer for Windows XP and newer. – Colin Pickard Aug 23 '10 at 19:36
yes deltree is an old DOS command. It was removed in XP and replaced by rmdir /s – heavyd Aug 23 '10 at 19:39
What does the /s flag stand for? – Mike R Mar 23 '15 at 15:45
@MikeR, it might stand for "subdirectories" or something. findstr has the same parameter, which makes more sense it its case, so maybe they're just the same for consistency. – Sam May 6 '15 at 23:58

If you want to delete a long and complicated folder structure from the command prompt that RmDir won't touch and not even explorer can display, I've found robocopy can be very efficient at removing the structure. In the example below we have a massive structure inside the folder administrator, the structure is so deep that nothing can remove it. We create a new empty folder called (strangely enough!) "new folder". We then use the robocopy command, telling it the source folder is "new folder" and the destination folder is "D:\Administrator" with the /MIR parameter which means it will purge anything not in the source folder.

robocopy "D:\new folder" D:\Administrator /MIR

In this case the folder paths were so long they would not even fit in the command prompt window Screen Buffer, but Robocopy will traverse the structure and remove any "extra" files and folders (ie anything not in the new empty folder, which is everything).

share|improve this answer
This is the only solution that will work when your path is more than 250 odd chars long – Calm Storm Feb 12 '13 at 16:24

You can do the following in PowerShell, if you're on Windows Vista+ :

rm C:\path\to\delete -r -f[orce]
share|improve this answer
Windows 10 says -f is ambiguous. But you can run rm -r -force <path> – BrunoLM Nov 6 '15 at 19:21

If you have a really really long path, (like I did because of java program error), even robocopy cant do it. It descended for about 30sec into my path and then hung.

My solution: if you can move the whole problem path from one folder to another then you can cut away recursivly and repeatedly some directory stairs from the top.

This Batch plays pingpong between the two directories leer and leer2 and cuts away 8 'libraries' each time. If your path contains files, you have to add further commands to erase them.

move c:\leer\libraries\libraries\libraries\libraries\libraries\libraries\libraries\libraries c:\leer2
rd /S /Q c:\leer\libraries
move c:\leer2\libraries\libraries\libraries\libraries\libraries\libraries\libraries\libraries c:\leer
rd /S /Q c:\leer2\libraries
GOTO loop
share|improve this answer

From CMD Just run RD /s C:\path\to\delete Hit Y to the prompt

/s ensures all the sub directories are deleted as well.

Reference Run help RD from the command line

share|improve this answer
Thanks for your answer, but this information was already in the accepted answer. (rd and rmdir are the same.) Perhaps it would fit as a comment there. – Ben N Jan 22 at 23:59

For me, what works is

del /s dir

You can add /q to disable confirmation. I've never managed to get rmdir working (on XP)

share|improve this answer
You should probably stop using XP, it isn't supported anymore ... – Eric Wilson May 17 '14 at 17:20

You can use ROBOCOPY. It is very simple and can also be used to delete empty folders inside large hierarchy.

ROBOCOPY folder1 folder1 /S /MOVE

Here both source and destination are folder1, as you only need to delete empty folders, instead of moving other files to different folder. /S option is to skip copying(moving, in the above case) empty folders. It is also faster as the files are moved inside the same drive.

share|improve this answer
But this would not delete non-empty folders? I think the question is about deleting all, both empty and non-empty. – Arjan Sep 13 '15 at 11:19

You must log in to answer this question.

protected by Community Jan 22 at 13:10

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged .