In order to delete a directory (dir) on your Mac running macOS via the Terminal application you can make use of the rmdir command
Syntax:rmdir path-of-the-directory - if the dir is empty
rm -r path-of-the-directory
Example:
Let's first create a directory in the Desktop and name it myDir, let's add a few files to it, I use the touch command just to create blank files abc.txt, xzy.csv so that the directory is not empty.
% mkdir myDir
% cd myDir
% touch abc.txt
% touch xyz.csv
% cd ..
% rmdir myDir
rmdir: myDir: Directory not empty
As you can see the myDir directory is not deleted as it is not empty, in order to delete the directory with files and folders in it you can make use of rm command with -r parameter.
Example:code2care@mac Desktop % rm -r myDir

Troubleshooting steps:
Note if the directory does not exist and you use the rmdir command you will get a "No such file or directory" error
code2care@mac Desktop % rmdir mydir1
rmdir: mydir1: No such file or directory

If the object you are trying to delete and it's not a directory - i.e. a file you will get an error like - Not a directory
code2care@mac Desktop % rmdir myfile.txt
rmdir: myfile.txt: Not a directory
Options that you can use with rm command
- -r :Recursive: remove directories and their contents recursively
- -f :Force: ignore nonexistent files, never prompt
- -i :Interactive: prompt before every removal
- -l :Interactive: only prompt before removing more than three files
- -r :Verbose: explain what is being done

Have Questions? Post them here!
- How to find path of file on Mac Terminal
- How to disable Siri on Mac Monterey
- [fix] macOS Ventura xcrun: error: invalid active developer path missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
- Select Line Number TextEdit on Mac
- Go to Specific file path using Mac Finder
- How to find Java HOME in Mac Terminal
- bash: command not found error [macOS Terminal Linux, Unix or Windows]
- Must Know Homebrew Commands for Mac/Linux Users
- How to Insert an Inverted Question Mark on Mac ¿
- Hide Keyboard Text Input Icon on macOS Ventura Menu Bar
- How to make macOS Terminal window Transparent (or Opaque)
- How to check of Updates on Microsoft Edge Browser on Mac (macOS)
- Limit scrollback rows in macOS Terminal
- How to identify installed Java (JDK) Version on macOS
- Keyboard Shortcut to delete a file on a Mac [Macbook]
- Open Docker from Terminal Command on Mac
- Installing MongoDB on Linux/Unix/macOS/Ubuntu
- How to take a screenshot on a Mac - updated for Ventura 13 [updated 2023]
- ls: .: Operation not permitted - Mac Terminal ZSH Error
- How to remove username from Mac Menu Bar?
- macOS Ventura XCode Command Line Tools Installation
- Where is .zshrc file located in macOS
- How to Show Path of Files or App in Mac Spotlight Search
- How to enable root user on Mac Terminal
- Install Java 17 (LTS) JDK on ARM based M1/M2 Mac Natively
- [Android Studio] Could not automatically detect an ADB binary - Android-Studio
- Google Chrome Update failed (error: 12) - Chrome
- Create simple struts2 project using maven commands - Java
- Notepad++ Happy vs Unhappy Versions - NotepadPlusPlus
- How to Display Analog Clock on Mac Menu Bar - MacOS
- How to Clear Cache for a website (URL) in Safari for Mac - MacOS
- Turning Off Chat in Gmail - Google
- Android Lint app_name is not translated in af (Afrikaans) am (Amharic) ar (Arabic) bg (Bulgarian) - Android