How to find and delete empty folders on Windows
Three safe ways to find and delete empty folders on Windows, why some folders only look empty, and which empty folders you should leave alone.
Written by the team building Quick File Organizer, folders that organize themselves, by your rules.
After a big clean-up, an uninstalled program or a round of sorting, you are left with shells: folders with nothing in them, sometimes nested five deep. File Explorer has no button to find them. Here are three ways to delete empty folders on Windows without touching anything that still holds a file.
Method 1: PowerShell, with a preview
This lists every empty folder under D:\Files, including ones that contain
only other empty folders:
Get-ChildItem "D:\Files" -Directory -Recurse |
Sort-Object { $_.FullName.Length } -Descending |
Where-Object { -not (Get-ChildItem -LiteralPath $_.FullName -Force) } |
Remove-Item -WhatIf
The sort puts the deepest folders first. That order matters: once an empty child is removed, its parent may become empty too, and it is checked afterwards.
-WhatIf prints what would be removed and deletes nothing. Because nothing is
really deleted in a preview, parents that only contain empty folders will not
appear in the list yet. Read it, then remove -WhatIf and run the command
again.
Remove-Item here deletes permanently, not to the Recycle Bin. Since the
folders are empty, there is nothing to lose except the folder names.
Method 2: one line in Command Prompt
The rd command refuses to remove a folder that has anything in it, which
makes it a safe tool for this job:
for /f "delims=" %d in ('dir "D:\Files" /ad /b /s ^| sort /r') do rd "%d"
dir /ad /b /s lists every subfolder, sort /r reverses the list so children
come before parents, and rd removes the ones that are empty. You will see
"The directory is not empty" for every folder that still has files — that
message is the safety check working, not an error to fix.
In a .bat file, write %%d instead of %d.
Method 3: a dedicated tool
If you prefer to tick boxes, a small utility such as Remove Empty Directories
(RED) scans a folder, shows the empty ones in a tree and lets you exclude any
you want to keep. It is also the easiest way to ignore junk files like
Thumbs.db when deciding what counts as empty.
Why a folder looks empty but is not
A folder that seems empty in Explorer can still fail to delete, or be skipped by the commands above. Usual reasons:
- Hidden system files.
desktop.inistores a folder's custom icon or view, andThumbs.dbcaches thumbnails. Turn on View → Show → Hidden items to see them. - Files with hidden extensions or zero size. Still files; the folder is not empty.
- Cloud placeholders. OneDrive folders may contain online-only items that some tools do not count.
The PowerShell command uses -Force so hidden files count as content, and
those folders are left alone. If you want folders containing only desktop.ini
removed too, delete those files first.
Empty folders you should keep
Not every empty folder is rubbish:
| Folder | Why it is empty | Delete? |
|---|---|---|
Inside C:\Windows, Program Files, AppData | Programs expect them to exist | No |
| Project templates, Git repositories | Structure kept on purpose | No |
| Camera or phone import folders | Recreated on the next import | No harm, but pointless |
| Leftovers in Documents, Downloads, Pictures | Old sorting, uninstalled apps | Yes |
The rule of thumb: delete empty folders only inside locations you manage yourself.
Where empty folders come from
They are a side effect of moving files. Sorting by hand, dragging things out of old project trees, extracting archives and deleting the contents — each leaves a shell behind. A deep, complicated tree produces more of them; a flat folder structure produces almost none.
Automated sorting helps for the same reason. When new files go straight to a small set of destination folders, there are no temporary piles to clear and no shells left afterwards. See how to organize files on Windows.
Common questions
Do empty folders take up disk space?
Almost none — an empty folder is a small entry in the file system. Removing them is about clarity, not space. To free real space, see what is taking up space on Windows.
Can Windows delete empty folders automatically?
Not by itself. Storage Sense removes temporary files and old downloads, not folders. You can schedule the PowerShell command in Task Scheduler to run weekly on a specific folder.
Why does Windows say the folder is in use?
Another program, or an Explorer window, has it open. Close windows showing that folder and try again — or see file is open in another program.