rmdir

Remove Directory (Delete folders).

Syntax
          rmdir [-p] folder ...

key
   -p      Each folder argument is treated as a pathname of which all components
           will be removed, if they are empty, starting with the last most component.
           (See rm for fully non-discriminant recursive removal.)

The rmdir utility removes the entry specified by each folder argument, provided it is empty.

Arguments are processed in the order given. To remove both a parent and subfolder, the subfolder must be specified first so the parent is empty when rmdir tries to remove it.

If an error occurs, rmdir exits with a value >0.

Examples

To delete all these folders:

MyFolder/
MyFolder/SubFolder
My Other Folder/

Use the command

rmdir MyFolder/SubFolder MyFolder "My Other Folder"

“Two years ago, I reported that Katherine Harris and Jeb Bush ordered county election officials to erase 57,000 voters from voter rolls - most of them Black. It cost Gore the White House” ~ Greg Palast

Related macOS commands

Local man page: rmdir - Command line help page on your local machine.
cd - Change Directory.
cp - Copy files.
find . -type d -empty -delete  - Delete all empty directories.
ls - List information about files.
pwd - Print Working Directory.
rm - Remove files or folders (including recursive delete).
trash - Move files and directories to the trash
trimforce - Enable TRIM commands on third-party drives.


 
Copyright © 1999-2026 SS64.com
Some rights reserved