Skip to main content

We’d like to load Google’s advertising tag to measure how our ads perform. It sets cookies and is optional. Privacy policy.

Mudry
Guides

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.

Roman Modrytskyi5 min read

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.ini stores a folder's custom icon or view, and Thumbs.db caches 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:

FolderWhy it is emptyDelete?
Inside C:\Windows, Program Files, AppDataPrograms expect them to existNo
Project templates, Git repositoriesStructure kept on purposeNo
Camera or phone import foldersRecreated on the next importNo harm, but pointless
Leftovers in Documents, Downloads, PicturesOld sorting, uninstalled appsYes

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.

Was this useful?

Quick File Organizer

Folders that organize themselves, by your rules. Free, no account.

See Quick File Organizer

Keep reading

Know when the next app ships

1 more Windows utility is in development. One short email when each one is ready — nothing else.

Product releases only — roughly once a month. Unsubscribe any time.