rmdir - macOS


rmdir is a command-line utility used to remove empty directories in macOS. It is particularly useful for managing and organizing disk space.


rmdir [options] directories…

Required Arguments:

  • directories…: A space-separated list of directories to be removed.


  • -p: Remove directories along with their parent directories if they are empty.
  • -v: Enable verbose mode, printing the path of each directory removed.
  • -f, –force: Remove directories without prompting for confirmation.


  • Remove an empty directory named “old_files”:
rmdir old_files
  • Recursively remove an empty directory and its empty parent directories:
rmdir -p old_files/backup
  • Remove multiple directories with verbose output:
rmdir -v tmp/dir1 tmp/dir2
  • Forcefully remove a directory without prompting:
rmdir -f protected_folder

Common Issues

  • Permission Denied: Ensure you have the necessary permissions to remove the directories.
  • Directory Not Empty: rmdir cannot remove non-empty directories. Use the -p option to recursively remove empty subdirectories.
  • Nested Symbolic Links: If the directory contains nested symbolic links, rmdir will not remove it. Use -p with caution in such cases.


  • Use find to search for and remove multiple empty directories:
find /path/to/dir -empty -type d -exec rmdir {} \;
  • Combine with mkdir to create and remove a temporary directory:
mkdir tmp_dir
rmdir tmp_dir
  • mkdir: Creates new directories.
  • find: Searches for files and directories.
  • rm: Removes files and directories.
  • rmdir: Official macOS documentation for rmdir.