Quick Windows tip: how to delete a complete folder tree from the command line?

Posted: (EET/GMT+2)

 

The situation: you are stuck with the Windows command prompt, and your task is to quickly delete a complete directory tree with about 30 sub-folders and about 2000 small files. Yes, you could use the DEL and RD commands, but it would take a long time to go through every sub-folder there is.

What is a better way? To note that at least since Windows XP, the RD command (or RMDIR) has the ability to delete both files *and* folders. In addition, it has the powerful switch /S, which allows you to work with subdirectories. A quick example:

RD /S C:\MyPath\DeleteThisFolder

Remember, that the RD utility will only ask once for a confirmation. So take care when using the command, and remember your backups.