To delete a folder on Windows, select it in File Explorer and press Delete; on a Mac, select it in Finder and press Command-Delete. Both move the folder to the Recycle Bin or Trash, where it stays until you empty it.
This article covers the keyboard and menu methods on each system, how to delete a folder permanently, the Command Prompt and PowerShell commands, and what to do when a folder refuses to go. On Linux, see how to delete a directory in Linux.
How to delete a folder on Windows
In File Explorer:
- Select the folder.
- Press Delete, or right-click the folder and choose the delete option in the context menu.
- Confirm if Windows asks.
Microsoft's shortcut list gives Ctrl+D or Delete as "Delete the selected item and move it to the Recycle Bin." The folder and everything inside it goes together.
Delete a folder permanently on Windows
Select the folder and press Shift+Delete. Microsoft's list describes it as "Permanently delete the selected item without moving it to the Recycle Bin." You skip the safety net, so check the folder name twice before you confirm. If the data is sensitive and you want it harder to recover, see how to securely delete files, because an ordinary delete does not promise that.
How to delete a folder on a Mac
Apple's steps in Finder:
- Drag the folder to the Trash in the Dock, or select it and press Command-Delete.
- If the folder is locked, click Continue to confirm you want to move it to the Trash.
- To remove it for good, empty the Trash. Click the Empty button in the upper-right corner of the Trash window, or choose Finder > Empty Trash, then click Empty Trash in the warning.
Apple states that "any items emptied from the Trash are permanently deleted and are no longer available." Until then the folder stays in the Trash.
Delete a single folder inside the Trash
To remove one item without emptying everything, open the Trash, Control-click the folder, and choose Delete Immediately. To skip the confirmation warning once when you empty the Trash, hold Option while you click Empty or choose Empty Trash. Apple says you can turn the warning off by clearing "Show warning before emptying the Trash" in the Advanced pane of Finder settings.
Get a deleted folder back on a Mac
While the folder is still in the Trash, drag it out, or select it and choose File > Put Back. After the Trash is emptied, this no longer works.
How to delete a folder in Command Prompt
The rmdir command (also rd) removes a directory. Microsoft's syntax is rmdir [<drive>:]<path> [/s [/q]]. These commands delete permanently. They do not use the Recycle Bin, so check the path before you press Enter.
To delete an empty folder:
rmdir "C:\work\old-folder"
To delete a folder and everything inside it, add /s, which Microsoft describes as deleting "a directory tree (the specified directory and all its subdirectories, including all files)":
rmdir /s "C:\work\old-folder"
Command Prompt asks for confirmation. Adding /q (quiet mode) removes that prompt, and it only works together with /s:
rmdir /s /q "C:\work\old-folder"
Microsoft's own caution applies: in quiet mode the whole tree is deleted without confirmation. Quote any path that contains spaces.
How to delete a folder in PowerShell
Remove-Item deletes files, folders and other items. Aliases include del, erase, rd and ri on all platforms, plus rm and rmdir on Windows. Add -Recurse to delete a folder together with its contents:
Remove-Item -Path "C:\work\old-folder" -Recurse
Without -Recurse, a folder that contains items triggers a confirmation prompt. Microsoft notes that -Confirm:$false does not suppress that prompt, by design. To preview a delete without running it, add -WhatIf:
Remove-Item -Path "C:\work\old-folder" -Recurse -WhatIf
If the path contains square brackets, use -LiteralPath instead of -Path. Microsoft says -LiteralPath is used exactly as typed, with no characters read as wildcards, whereas -Path accepts wildcards. A wildcard in a delete command can match more than you intended.
How to delete a folder in the Mac Terminal
The Mac Terminal uses the same Unix command as Linux, rm with the recursive option. It deletes permanently and does not move anything to the Trash. The flags, the safe way to check what you are about to remove, and the difference from rmdir are covered in the Linux directory guide. For most Mac users, Command-Delete in Finder is the safer route.
Why you can't delete a folder
- "The directory is not empty" in Command Prompt. Microsoft says you can't delete a directory that contains files, including hidden or system files. Use
rmdir /s, or list everything withdir /afirst. Microsoft's documented route for stubborn hidden or system files isattribwith-h,-sor both to remove those attributes, then delete. - "The process can't access the file because it is being used by another process." This is the message Microsoft documents when you try to remove the current directory with
rmdir. Change to a different directory that is not a subfolder of the one you are deleting, then run the command again:cd ..goes up one level. - Hidden or read-only items in PowerShell. Microsoft says
-ForceletsRemove-Itemdelete hidden or read-only items, and that even with-Forcethe cmdlet can't override security restrictions. If a folder fails that way, the account you are using probably lacks permission. - A locked folder on a Mac. Finder asks you to click Continue to move a locked item to the Trash. Apple's guide does not cover items that are in use, so if the Trash refuses to empty, quit the apps that might have files from the folder open and try again.
Which method should you use?
| Method | System | Goes to Recycle Bin or Trash? | Recoverable afterwards? |
|---|---|---|---|
| Delete or Ctrl+D | Windows | Yes (Recycle Bin) | Yes, until the Recycle Bin is emptied |
| Shift+Delete | Windows | No | Not from the Recycle Bin |
rmdir /s | Windows | No | Not from the Recycle Bin |
Remove-Item -Recurse | Windows | No | Not from the Recycle Bin |
| Command-Delete | Mac | Yes (Trash) | Yes, with Put Back, until the Trash is emptied |
| Delete Immediately | Mac | Removes it from the Trash | No, per Apple |
The Recycle Bin column for the command-line methods follows Microsoft's wording for the shortcut and the command documentation: none of the rmdir or Remove-Item pages mention the Recycle Bin, so treat those commands as permanent. If you only need to change a folder's name rather than remove it, see how to rename a folder.
Frequently asked questions
- What is the shortcut to delete a folder?
- On Windows, select the folder in File Explorer and press Delete (or Ctrl+D) to move it to the Recycle Bin. On a Mac, select it in Finder and press Command-Delete to move it to the Trash.
- How do I delete a folder without sending it to the Recycle Bin?
- On Windows, select the folder and press Shift+Delete. Microsoft describes this as permanently deleting the selected item without moving it to the Recycle Bin. On a Mac, move the folder to the Trash and then empty the Trash, or Control-click it inside the Trash and choose Delete Immediately.
- Can I get a deleted folder back?
- If it is still in the Recycle Bin or the Trash, yes. On a Mac, select it in the Trash and choose File > Put Back. Once the Trash is emptied, Apple says the items are permanently deleted and no longer available.
- Why does Command Prompt say the directory is not empty?
- The rmdir command cannot delete a directory that contains files, including hidden or system files. Add /s to delete the whole tree, or empty the folder first.