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


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.

3 Responses to “The deltree command equivalent for Windows 2000, Windows XP, Windows Server 2003, and beyond”

  1. Robert Says:

    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?

  2. DeeZaster Says:

    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.

  3. joe Says:

    rd directoryname /s dose so work. Thanks


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: