sodcalculator

10 Tech How-To

Remove Empty Directories in Windows 10

Guide 10-36080 · Updated · Step by step

This guide shows you how to find and delete empty folders in Windows 10, either manually or with a simple command, to keep your file system tidy. You’ll need a Windows 10 PC and, for the automated method, a basic understanding of using Command Prompt.

What You’ll Need

  • A Windows 10 computer with administrator access (optional but recommended for system folders).
  • Basic familiarity with File Explorer and, for the command-line method, Command Prompt.

Step-by-Step

Method 1: Manual Deletion (for a few folders)

  1. Open File Explorer (Win + E).
  2. Navigate to the drive or folder where you want to remove empty subfolders.
  3. Click the View tab and check Hidden items to see hidden empty folders (they are often empty but hidden).
  4. Right-click on an empty folder and select Delete. If it’s not empty, Windows will ask for confirmation; if it is empty, it deletes immediately.
  5. Repeat for each empty folder. This is fine for a handful but tedious for many.

Method 2: Using Command Prompt (for many folders)

  1. Open Command Prompt as administrator: press Win + X and select Command Prompt (Admin) or Windows PowerShell (Admin).
  2. Type the following command and press Enter. Replace C:\path\to\your\folder with the actual path (e.g., D:\Downloads). This command lists all empty subfolders under that path, including hidden ones.
    dir /s /b /ad "C:\path\to\your\folder" | sort /r
  3. To delete them all in one go, use this command. It removes all empty directories in the specified path, including nested ones. Be careful—this is permanent and does not ask for confirmation.
    for /f "delims=" %i in ('dir /s /b /ad "C:\path\to\your\folder" ^| sort /r') do rd "%i" 2>nul

    Note: If you are running this in a batch file, double the percent signs (%%i).

  4. After running, check that the folders are gone. The 2>nul suppresses errors for folders that are not empty (so they remain).

Method 3: Using PowerShell (alternative)

  1. Open PowerShell as administrator (Win + X, then choose Windows PowerShell (Admin)).
  2. Run this command to find empty directories in a path:
    Get-ChildItem -Path "C:\path\to\folder" -Recurse -Directory | Where-Object { (Get-ChildItem $_.FullName -Force).Count -eq 0 } | Remove-Item -Force -Recurse

    This removes all empty directories recursively. It also deletes hidden empty folders because of the -Force flag.

Common Mistakes

  • Not checking hidden items: Many empty folders are hidden by default, so they won’t show in File Explorer unless you enable hidden items.
  • Deleting system folders: Some empty-looking folders are needed by Windows or apps. Avoid deleting folders in C:\Windows or C:\Program Files unless you are certain they are safe.
  • Using the command without testing: The command-line method deletes instantly without a recycle bin. Test on a small folder first.
  • Forgetting the 2>nul in the for command: Without it, you’ll see error messages for folders that aren’t empty, but it still works. With it, errors are hidden.

Tips

  • Before deleting, run the dir command to see a list of what will be removed. You can redirect the output to a text file for review: dir /s /b /ad "C:\path" > empty_folders.txt.
  • If you want to remove empty folders on a schedule, create a batch file with the for command and run it via Task Scheduler.
  • Use the rd command with the /s flag to remove a folder and its subfolders, but that removes non-empty ones too, so avoid it here.
  • For a graphical approach, you can sort folders by size in File Explorer (View > Sort by > Size) to spot empty ones (size 0 KB).

Troubleshooting

  • Command says “The system cannot find the file specified”: This usually means the path is incorrect. Double-check the path, including drive letters and backslashes. Use quotes around the path if it contains spaces.
  • Folders are not deleted even though they appear empty: They might contain hidden files or system files. Use the -Force flag in PowerShell or the /a switch in the dir command to include hidden files. For example: dir /s /b /ad /a "C:\path".
  • Access denied errors: Some folders are protected by Windows. Run Command Prompt or PowerShell as administrator. If that fails, the folder might be in use; close any programs that might be using it.
  • The command deletes non-empty folders too: The for command with rd should only remove empty ones because rd fails on non-empty folders. If you used rd /s, that would delete everything. Make sure you did not include /s.
  • PowerShell command errors with “Cannot bind argument”: This is often a quoting issue. Ensure the path is in quotes and that you are using the exact syntax. Try running the command without the -Recurse first to test.

Frequently Asked Questions

Will deleting empty folders speed up my PC?

Generally no, empty folders take up negligible disk space. The main benefit is organizational—it makes it easier to navigate your files.

Can I recover deleted empty folders?

If you delete them manually (via File Explorer), they go to the Recycle Bin and can be restored. If you use the command-line method, they are permanently deleted and cannot be recovered easily. Always double-check before running the command.

Why do some empty folders reappear after deletion?

Certain applications (like cloud sync services, anti-virus, or system processes) may recreate folders they expect to exist. If a folder keeps coming back, it’s likely needed by a program—consider leaving it.

How do I delete empty folders in a specific folder without touching subfolders?

Use the command without /s in the dir part, or manually select them. For example: for /f "delims=" %i in ('dir /b /ad "C:\path"') do rd "C:\path\%i" 2>nul – this only checks immediate subfolders.

Is there a way to see empty folders in File Explorer?

Yes, switch to Details view and add the Size column. Empty folders will show 0 KB. You can also sort by size to group them.

Can I use third-party tools to do this?

Yes, many file management tools have a “find empty directories” feature. However, the built-in methods above are free and safe, so third-party tools are not necessary.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →