Just a short tip for today. I was required to create a batch to automatically remove a directory as well as all of its subdirectories and contained files. I remembered many years ago when I was using Windows 98, I could use the “deltree” command to delete a folder and everything in it.

I launched command prompt(DOS), and typed “deltree /?” to display all the commands for deltree because I couldn’t remember the deltree parameters. I was quite embarrassed to see the error message “deltree is not recognized as an internal or external command, operable program or batch file.” It seems that the deltree command is no longer being used in Windows 200 and Windows XP.
Dos command to delete directory
After a little searching, I found deltree command replacement for Windows 2000 and Windows XP.

Windows 2000 and Windows XP do not have deltree command, but you can emulate it with the RD or RMDIR command.
Deltree in Windows XP

For example, the following Windows 2000 or Windows XP DOS command deletes the C:\RAYMOND directory and all subdirectories WITHOUT ANY WARNING:

RD C:\RAYMOND /S /Q

/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.

I remembered back in Windows 98 time, the RD command is used to remove empty directories in MS-DOS. To delete directories with files or directories within them the user must use the deltree command. It looks like Windows 2000 and Windows XP has updated the RD command with the /S option. If you didn’t know, the RD and RMDIR command are internal commands for DOS. You couldn’t find a file rd.exe or rmdir.exe in your system.

DOS is still very useful to me. I get to automate task or even removing spywares or virus by running a DOS batch file.

[tags]rd, rmdir, dos, deltree, batch[/tags]