We can delete a directory or folder from command line using rmdir command. See syntax below
C:\>rmdir emptydir C:\> C:\>rmdir nonemptydir The directory is not empty. C:\>rmdir /S nonemptydir nonemptydir, Are you sure (Y/N)? y C:\>
As you can see in the above examples, we need to use /S to delete a non empty directory.
To delete directory in quiet mode, without being asked for confirmation, we can use /Q switch.
rmdir /Q /S nonemptydir
We can also use ‘rd’ in place of ‘rmdir‘. Both names refer to the same command. This command works on Windows 2000, Windows XP, Server 2003, Vista and Windows 7.
Deleting directory with white spaces in the name :
You can specify the directory name in quotes. See the example below.
rmdir /Q /S "folder with spaces in the name"
To delete a directory, you should have appropriate access permissions on the directory. Otherwise you would get ‘Access denied’ error.