tags:

views:

726

answers:

3

In earlier versions of MS-DOS - I want to say version 7, but I could be wrong - there was a deltree command, which recursively deleted all subdirectories and files from a given path.

deltree no longer exists, but del didn't seem to inherit the ability to delete a tree. del /s deletes files, but not folders.

How to you easily (i.e., in one command) delete a tree from a DOS batch file?

+1  A: 
rmdir /s /q directory
Jon Skeet
+8  A: 

It was replaced with the commands: RMDIR or RD

Delete all subdirectories with /S

Use it quietly with the /Q

Example:

RMDIR /S /Q Folder2Delete
RD /S /Q Folder2Delete

Documentation:

Jeremiah
+2  A: 
$ help rd
Removes (deletes) a directory.

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
Ferruccio