Windows rmdir Command Tutorial

Windows rmdir command is used to remove or delete directories in windows via command-line interface. The rmdir command can be used via MS-DOS or PowerShell command prompts. The usage of the rmdir command is very simple and provides very few parameters.

rmdir Command Syntax

The rmdir command has the following syntax where options can be specified after the directory specification.

rmdir OPTION DIRECTORY 
  • DIRECTORY is the directory name or name with or without path.
  • OPTION is the option for rmdir which is optional.

Delete Directory

The rmdir command can be used to delete a single directory that is located in the current working directory. We just provide the directory name which is db in this case.

> rmdir db

If the directory is located in a different path than the current working directory the complete or absolute path can be specified.

> rmdir C:\db

Delete Multiple Directories

The rmdir command can be also used to delete multiple directories at once. The directories are provided by separating with spaces.

> rmdir db myfiles temp

Delete Directories Recursively

The rmdir command deletes empty directories by default but if we need to delete directories with some child directories or files we should use the recursive option. The /s option is used to delete directories recursively with all their contents.

> rmdir /s db 

Delete Directories Recursively without Confimation

By default recursive delete of directories requires approval in order to prevent errors and mistakes. This approval will be required for every file and directory which can be a boring and trivial task if there are a lot of child directories or files. We can make things more practical for the recursive delete by using the /q option to approve all delete operations automatically.

> rmdir /s /q db 

Leave a Comment