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.

Posted in Windows. Tags: , , , , . 1 Comment »

One Response 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?


Leave a Reply