tags:

views:

4296

answers:

10

I need a way to recursively delete a folder and its children, is there a prebuilt tool for this, or do I need to write one?

DEL /S doesn't delete directories.

DELTREE was removed from Windows 2000+

A: 

http://www.computerhope.com/delhlp.htm

del /s
wnoise
Doesn't delete the directories.
FlySwat
+1  A: 

rmdir /s dirname

Brian Mitchell
A: 

Try this command:

del /s foldername
yjerem
+9  A: 

RMDIR or RD:

rd /s /q
Duncan Smart
It's worth pointing out that for large numbers of files, rmdir /s /q is typically significantly faster than the equivalent "select dir, shift + delete" operation in explorer.
Wedge
Thanks!! This helped me. Now if I can just get used to typing 'dir' instead of 'ls'
Derek
How about using flags to match directory names? If I want to drop all directories under foo\, `rmdir /s /q foo\*` gives an error for syntax incorrect.
Thomas G. Mayfield
+1  A: 

rmdir /S /Q %DIRNAME%

Branan
+2  A: 

RMDIR [/S] [/Q] [drive:]path

RD [/S] [/Q] [drive:]path

  • /S Removes all directories and files in the specified directory in addition to the directory itself. Used to remove a directory tree.

  • /Q Quiet mode, do not ask if ok to remove a directory tree with /S

Jim McKeeth
+1  A: 

You can install cygwin, which has rm as well as ls etc.

A: 

There is also deltree if you're on an older version of windows.

I really like this site for finding commands: SS64: Del - Delete Files

Jason Wadsworth
+2  A: 

admin:

takeown /r /f folder
cacls folder /c /G "ADMINNAME":F /T
rmdir /s folder

Works for anything including sys files

wbkang
A: 

You can install GnuWin32 and use *nix commands natively on windows. I install this before I install anything else on a minty fresh copy of windows. :)

epochwolf