Skip to main content

Command referencermdir

rmdir command (Windows / CMD)

WindowsCMDfilebeginner

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 / optionMeaning
/SRemove all files and subdirectories in the tree.
/QSuppress confirmation when used with /S.
pathSelect 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.

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.