RMDIR - XP's Version of Deltree

Deltree has always been an extremely useful DOS-based utility.  Unfortunately it was not included with WinXP - but it will work just fine, simply copy it into the Windows folder from a Win98 machine.  Better yet - use the utility that XP did include  .  .  .  rmdir.  

Of course, "rmdir" has different options and switches than deltree, so I just copied deltree into my Windows folder from my Win98 partition and I'm done with it.  If you cannot get your hands on a Win98 copy of "deltree.exe" you can

download deltree here, or use Notepad to write the following batch file that emulates deltree perfectly . . . and then save it as "deltree.bat".  There are 2 possible cases:

  1. if the user types in deltree folder with a /y or /Y it will delete the folder without asking for permission to, and it will know to use the "2nd" command-line option (%2) since the first option is /yor /Y
  2. if the user does not use a /y or /Y then it will ask him if he is sure he wants to delete the folder,  and it will know to use the "1st" command-line option (%1) since there is only one option that was typed in 

@echo off
IF "%1"=="/Y" GOTO NO_ASK
IF "%1"=="/y" GOTO NO_ASK
RMDIR /S %1
GOTO END
:NO_ASK
RMDIR /S/Q %2
:END

A full Comparison of the three DOS Commands that can Delete a Folder:

  .   .  .  Del  vs  Deltree  vs Rmdir  (Del on Win98-XP,  Deltree on Win98,  RMdir on WinXP)

del  /q  foldername  -  will delete the files in the folder.  It will not delete the folder, nor will it delete any subfolders

deltree  /y  foldername  -  deletes the entire folder structure including all files and subfolders.  You will need to copy the file from a Win98 machine since WinXP does not have Deltree.  

rmdir  /s /q  foldername  -  same as deltree /y - deletes the entire folder structure including all files and subfolders.

*** so in general, use RMDIR but make sure to recreate the folder if it is needed

RMDIR Explained

Removes (deletes) a directory and all of it's files and subfolders.  

If you use no switches, then rmdir can only remove an empty folder (it will fail and tell you the folder is not empty).  So always use the /s switch !!

RMDIR [/S] [/Q] [drive:]path    or    RD [/S] [/Q] [drive:]path

   /S      Removes all Sub-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