The deltree command equivalent for Windows 2000, Windows XP, Windows Server 2003, and beyond

by admin on January 5, 2009

Good old DOS and versions of Windows prior to Windows 2000 included the deltree.exe command. The deltree command could remove a directory and all the files the directory contained. Subdirectories could also be deleted when the /s option is used. This was extremely helpful for removing a directory structure that contained many files and folders. It’s usually much faster to delete files from the command line, rather than through Windows Explorer.

To remove multiple levels of files and directories in Windows operating systems that do not have deltree.exe, use the rd.exe or rmdir.exe command:

rd directoryname /s
or
rmdir directoryname /s

where directoryname is the name and path to the directory you want to remove. This will also delete all files and subdirectories.

Use the following command to remove all files from a directory and it’s subdirectories while maintaining the directory structure:

del *.* /s /q

This uses the del.exe command to delete all files from the current directory and subdirectories. The /q option instructs del.exe to run in quiet mode and not to prompt you to remove every folder it encounters.

Related Posts

{ 3 comments… read them below or add one }

Robert May 12, 2009 at 11:30 pm

RD is not an equivalent of Deltree.
For example:

rd directoryname /s

will alway delete the directory itself.

But Deltree does not delete the directory itself if there is a backslash at the end of the directory name. That is what I am looking for in Windows XP.

Does anyone know a real equivalent command of Deltree in Windows XP other than a batch file?

Reply

DeeZaster August 11, 2009 at 3:27 pm

deltree (http://terrikaduck.netfirms.com/deltree.zip) works in Windows 7 32bit just fine but you will run into trouble with 64bit. rmdir /q /s works exactly the same but I just make a batch file for 64bit called deltree.bat and stick that into the system32 folder.

@rmdir /q /s %1

and your done. Thats all thats available for dos, unless you want to use Take Command (http://www.jpsoft.com/) which is a fantastic replacement. RD and rmdir are the same two commands, both only have two switches and do exactly the same for each one.

Reply

joe November 1, 2009 at 5:36 pm

rd directoryname /s dose so work. Thanks

Reply

Leave a Comment

Previous post:

Next post: