SOLVED: How To Delete a Folder and All Its Subfolders and Files Using Command Line

rmdir command lineIf you have a folder that may (or may not) contain other files and folders that you want to delete using a simple command line, RMDIR (as in Remove Directory) is your friend.

The syntax is simple are only two switches:

/S = also remove all sub-directories

/Q = Quiet / Silent / do not prompt user to confirm deletion

The following command will remove the McAfee folder AND everything under it.

rmdir /s /q "c:\Program Files\McAfee\"

There is no requirement to put the path in quotes unless you have long file names, but the quotes do not cause a problem so I use them on all rmdir commands

If files are in use, the command will complete successfully but leave those in use files / folders in place.

Alternately,  if RMDIR is just too many letters for you to type Microsoft has added an alias for this command.  You could just use RD in place of RMDIR.

Questions or Comments?