Command referencermdir
rmdir command (Windows / CMD)
What it does
Remove an empty directory or an entire directory tree. Searches for the rmdir command cmd usually need CMD syntax, practical switches, and notes on how it compares with PowerShell or Linux alternatives. This page covers syntax, common options, and copyable examples for Command Prompt.
Remove an empty directory or an entire directory tree.
Syntax
rmdir [/S] [/Q] [drive:]path
Common options
| Flag / option | Meaning |
|---|---|
| /S | Remove all files and subdirectories in the tree. |
| /Q | Suppress confirmation when used with /S. |
| path | Select the directory to remove. |
Practical examples
Remove empty folder
rmdir OldReports
Removes the folder only if empty.
Remove tree with prompt
rmdir /S Build
Asks before removing Build and its contents.
Quiet cleanup
rmdir /S /Q TempBuild
Removes a known temporary tree without prompting.
Linux ↔ Windows equivalent
Closest match: rm (Linux / bash / sh / zsh). Remove files and directory trees permanently.
Common mistakes
- Danger: combining `/S /Q` removes a complete tree without recovery or confirmation.
- Trying to remove the current directory.
- Using rmdir to delete a single file.
Related commands
- delPermanently delete one or more files.
- mkdirCreate a directory and any missing intermediate directories.
- rmRemove files and directory trees permanently.
- lsList directory entries and inspect file metadata.
- cdChange the shell's current working directory.
- dirList files and subdirectories with names, dates, sizes, and attributes.
- findWalk directory trees and select entries using tests and actions.
- Get-ChildItemEnumerate items and child items in filesystem, registry, and other providers.
FAQ
What does rmdir do in Command Prompt?
Remove an empty directory or an entire directory tree.
How do I run rmdir in CMD?
Open Command Prompt and follow `rmdir [/S] [/Q] [drive:]path`; quote paths containing spaces.
What is a practical rmdir example in CMD?
Try `rmdir OldReports` — Removes the folder only if empty.
Can rmdir be used in a batch file?
Yes. Check its exit code and escape CMD metacharacters when input is variable.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.