How to Delete Empty Folders on Windows 11 and Mac (4 Ways)
Delete empty folders with Command Prompt, PowerShell or Mac Terminal, learn what is safe to remove, and keep them from coming back with a scheduled File Arbor run.
To delete empty folders on Windows, one Command Prompt line removes every empty folder inside a folder you choose and refuses anything that still holds a file. PowerShell does the same with a preview, and on a Mac one Terminal command does it. This guide also covers what is safe to delete, why some folders won't go, and how to stop them coming back.
Why Empty Folders Pile Up
Empty folders are what other jobs leave behind:
- You sort or move files out of subfolders, and the folders they sat in stay behind.
- You unzip archives into Downloads and later move the contents elsewhere.
- A photo or phone import creates a dated folder per day, and you keep only the best shots.
- An uninstalled program leaves its folder tree behind.
- A project template or a scanner creates a folder per job, and some stay unused.
They take almost no disk space, so cleaning them up will not free gigabytes. The cost is clutter: longer folder lists and noise in backups and search results. A D:\Photos\Export with 140 dated subfolders, 90 of them empty, is tedious to scroll through.
Is It Safe to Delete Empty Folders?
Yes inside your own data folders: Downloads, Documents, photo exports, project archives, a USB drive.
No inside system and program folders. Do not touch C:\Windows, C:\Program Files, C:\ProgramData or AppData (the %AppData% folder) on Windows, or ~/Library, /System and /Applications on a Mac. Programs create empty folders they expect to find, such as logs, plugins and caches. Deleting one can break the program, or the program creates the folder again the next time it runs.
In a synced folder (OneDrive, Dropbox, iCloud Drive, Google Drive) the deletion syncs to your other devices.
The rule of thumb: point every method below at a folder you made, never at a drive root like C:\.
4 Ways to Delete Empty Folders, Compared
The methods differ in safety nets and in whether they can repeat on their own.
| Method | Works on | Removes nested empty folders | Folder holding only desktop.ini, Thumbs.db or .DS_Store | Where removed folders go | Preview first | Repeats on its own |
|---|---|---|---|---|---|---|
Command Prompt (rd) | Windows 10 and 11 | Yes | Kept, counts as not empty | Deleted permanently | No | No |
| PowerShell | Windows 10 and 11 | Yes | Kept, counts as not empty | Deleted permanently | Yes, with -WhatIf | No |
Terminal (find) | macOS | Yes | Kept, unless you delete .DS_Store first | Deleted permanently | Yes, run it without -delete | No |
| File Arbor (Pro) | Windows and Mac | Yes | Removed, those system files don't count | Recycle Bin or Trash, listed in History | Yes, the first scan shows what will happen | Yes, on a schedule |
"Deleted permanently" sounds alarming, but the three commands only ever remove folders that hold nothing, so there is nothing inside to lose.
Can File Explorer Find Empty Folders?
Partly. Explorer's search has a Size filter with an "Empty" value, typed as size:empty. It is not reliable. Results differ between Windows versions, some people get "No items match your search", and it can mix 0-byte files into the list.
You cannot trust it to select everything and press Delete. For an exact list, run the PowerShell command from Method 2 with -WhatIf. It prints every empty folder and deletes nothing.
Method 1: Delete Empty Folders With Command Prompt (Windows)
This works on Windows 10 and 11, with no admin rights for your own folders. Open Command Prompt (Start, type cmd, Enter), replace D:\Photos with your folder and run:
for /f "delims=" %d in ('dir "D:\Photos" /s /b /ad ^| sort /r') do rd "%d" 2>nul
How the line works:
dir /s /b /adlists every subfolder underD:\Photos.sort /rputs the deepest folders first, so a folder that becomes empty when its empty subfolder goes is removed in the same pass.rdwithout/sonly removes a folder that is empty and refuses one that holds anything: a file, a hidden file, a subfolder. That is what makes this line safe.2>nulhides those refusals.D:\Photositself is never removed.
In a .bat file, write %%d instead of %d. Hidden empty folders are removed too. Microsoft documents the command in Microsoft's rd reference.
We tested this line on Windows 11: nested empty folders went in one pass, while folders with a file or a hidden desktop.ini stayed.
Method 2: Delete Empty Folders With PowerShell (Windows 11 and 10)
Preview first, with your own folder in the first line:
$root = "D:\Photos"
Get-ChildItem -LiteralPath $root -Directory -Recurse |
Sort-Object { $_.FullName.Length } -Descending |
Where-Object { -not (Get-ChildItem -LiteralPath $_.FullName -Force) } |
Remove-Item -WhatIf
It prints a "What if:" line per empty folder and deletes nothing. When the list looks right, run it again without -WhatIf.
What it does:
- It sorts the longest paths first, so the deepest folders go first and chains of empty folders disappear in one run.
-Forcein the inner check counts hidden files as contents, so a folder holding onlydesktop.iniorThumbs.dbstays.- Hidden folders themselves are left alone.
The preview lists folders that are empty right now. A parent holding only empty folders is not in it, but the real run removes it in the same pass.
See Microsoft's Remove-Item reference. We tested this on Windows 11 with PowerShell 7.
Method 3: Delete Empty Folders on Mac With Terminal
Open Terminal from Applications → Utilities. Preview first:
find ~/Pictures/Exports -mindepth 1 -type d -empty
When the list looks right, delete:
find ~/Pictures/Exports -mindepth 1 -type d -empty -delete
-mindepth 1 keeps the folder itself even if it ends up empty. -delete works from the deepest level up, so nested empty folders go in one run. Deletion is permanent: nothing goes to the Trash. macOS may ask whether Terminal can access Desktop, Documents or Downloads. Allow it.
The .DS_Store catch
Finder writes a hidden .DS_Store file into folders you have opened, so find does not see those folders as empty. To count them as empty, delete the files first. It only resets those folders' Finder view settings:
find ~/Pictures/Exports -name .DS_Store -type f -delete
Then run the delete command again.
Method 4: Remove Empty Folders Automatically With File Arbor
The commands above are a one-off. If a folder keeps producing empty folders, you clean up again next week. Camera imports, Downloads folders full of unzipped archives and scanners that make a folder per day all do this. File Arbor 1.3.3 added an option that removes them after every run.
Setup, which needs Pro:
- Install File Arbor from the download page, click Add Folder and choose the folder.
- Tick Scan subfolders on the folder card. It works in Single mode, where you press Run, and in Scheduled mode.
- Under "How should files from subfolders be organized?", tick Move empty folders to the Recycle Bin.
- Give the folder at least one rule, because the cleanup runs after the rules. For example, a rule for Files with extension
.jpgand.heicwith Moves to set toAll photos. The guide to moving files out of subfolders shows that setup. - Press Run. The Confirm first scan dialog shows how many files and folders are involved, how deep the scan went, some sample moves, and the line "Empty folders go to the Recycle Bin after the run."
- Switch the folder to Scheduled, for example weekdays at 18:00, to repeat it.
What File Arbor counts as empty
- A folder holding only
.DS_Store,Thumbs.dbordesktop.inicounts as empty. Any other file, a hidden one included, keeps the folder. - The watched folder itself always stays, and so do Exclusions and everything inside them.
- A cancelled run removes no folders.
- Every removed folder is listed in History as Empty folder, and you restore it from the Recycle Bin, or the Trash on a Mac.
File Arbor is not a one-click tool that finds every empty folder on your drive. It cleans up the folders it organizes, as part of a run. For a single cleanup, Methods 1 to 3 are free and do the job.
The free plan is one watched folder, two rules, up to 20 files a day, manual runs, and it has no subfolder scanning. Subfolder scanning and this cleanup are Pro, which is $24.99 one-time (pricing). The docs on subfolders list every option.
Why Won't an Empty Folder Delete?
An "empty" folder that refuses to go is almost never empty. Check these causes:
- A hidden file is inside. Windows keeps
Thumbs.db(Explorer's thumbnail cache) ordesktop.inithere, and a Mac keeps.DS_Store. Show hidden items (Windows 11: View → Show → Hidden items; Mac: Command-Shift-period in Finder) and delete the file. - The folder is open somewhere. An Explorer window or the preview pane, a Command Prompt whose current folder it is, or a program with a file dialog open. Close it and retry.
- A sync app is still working on it. With OneDrive or Dropbox, wait for the sync to finish or pause it.
- Permissions. The folder was created by another account or an installer. Delete it as that account, or as administrator, but first ask whether it belongs to a program.
- The path is too long. On older Windows setups, more than 260 characters fails. Move the folder up a level or shorten a name, then delete.
Which Method Should You Use?
- A one-off cleanup on Windows: Method 1, the Command Prompt line.
- You want to see the list first: Method 2, PowerShell with
-WhatIf. - You are on a Mac: Method 3, and delete
.DS_Storefirst if Finder has been in those folders. - A folder that refills every week, or you are also moving files out of subfolders: File Arbor in Scheduled mode.
- System or program folders: none of them.
For the wider mess, see a full computer declutter and moving files to the Recycle Bin automatically.
FAQ
How do I delete all empty folders at once in Windows 11?
Open Command Prompt and run a for loop that lists every subfolder, sorts the list so the deepest folders come first, and runs rd on each one. Because rd without /s refuses any folder that holds something, only empty folders go, nested chains included, in one pass. The same line works on Windows 10. Replace the example path with your own folder first.
Is it safe to delete empty folders?
Yes, inside folders you made yourself, such as Downloads, Documents, photo exports or a USB drive. No inside system and program folders: Windows, Program Files, ProgramData, AppData on Windows and Library on a Mac. Programs create empty folders they expect to find. In a synced folder such as OneDrive, Dropbox or iCloud Drive, the deletion syncs to your other devices.
Why can't I delete an empty folder?
A hidden file is usually inside: Thumbs.db or desktop.ini on Windows, .DS_Store on a Mac. Other causes are a folder open in another program, a sync app such as OneDrive still working on it, missing permissions because another account or an installer created it, or a path longer than 260 characters on older Windows setups. Show hidden items, close the program, and retry.
How do I delete empty folders on a Mac?
Use Terminal. Run find with the folder, -mindepth 1, -type d and -empty to list empty folders, then add -delete to remove them, nested ones included. Deletion is permanent, not the Trash. Finder writes hidden .DS_Store files that make folders look non-empty, so delete those first. Finder itself has no filter for empty folders.
Can empty folders be deleted automatically?
Not with a built-in setting: neither Windows nor macOS has one. You can schedule a script that runs one of the commands above, or use File Arbor Pro, whose Move empty folders to the Recycle Bin option removes them after every run, scheduled runs included. Each removed folder is listed in History and can be restored from the Recycle Bin or Trash.
The Bottom Line
For a one-off, the Command Prompt line or the Terminal command takes a minute. When a folder keeps refilling with empty shells, let a scheduled File Arbor run sort the files and bin the folders.
Download File Arbor and try it on one folder: the free plan is one watched folder, two rules, up to 20 files a day, manual runs. Scan subfolders and Move empty folders to the Recycle Bin come with Pro, $24.99 one-time with lifetime updates and a 30-day refund; the pricing page lists the full split.