How to find and delete empty folders

How to find and delete empty folders


Empty folders might not eat up disk space, but they clutter your system. Every time you move files between your PC and Android, you get stuck. All the empty folders on your hard drive have the same names, and it turns into a wild goose chase every time. This issue can extend to system performance, causing lags during routine operations like backups and virus scans. It doesn’t matter if you use a budget Android phone or a gaming setup. Empty folders slow things down. This tutorial explores how to clean up your Windows PC and speed things up.



Back up your files before using command line deletions

When deleting files from the command line, you must be careful because you risk losing your data. These commands usually skip your operating system’s recycle bin. When you delete something, it’s gone unless you backed it up. Always back up important files regularly. If something goes wrong, you can recover your data.


Related

How to back up Windows 11

Microsoft keeps your data safe and secure, but regular back ups are still a good idea

You can delete more files and folders than you intended when using recursive methods. Always double-check the path you’re targeting in your command to make sure it’s exactly where you want it to be. Even a small typo can cause a mess.

Always thoroughly review the contents of any directory you’re about to delete. Look through the top level and all the nested directories to make sure everything in there is stuff you won’t miss. A good tip is to use listing commands for a dry run first. This shows you what will be deleted if you go ahead without deleting anything.

Using Command Prompt to find empty folders and delete them

Here’s how to find empty folders and delete them using Windows Explorer:


  1. Open the Start menu, type cmd, right-click, and select Run as administrator.
  2. In the Command Prompt window, type cd /d DriveName:\To\FolderPath, and press Enter to open your specified directory.
  3. To list empty files, run the following command: for /f “delims=” %d in (‘dir /ad/b/s ^| sort /R’) do @dir /b “%d” | findstr “^” >nul || echo %d
  4. After reviewing the list, if you decide to delete the empty folders, run this command: for /f “delims=” %d in (‘dir /ad/b/s ^| sort /R’) do @dir /b “%d” | findstr “^” >nul || rd “%d”
    Windows command prompt window with the codes to print and then remove empty folders

This code scans all the folders and subfolders from C:\To\FolderPath to find and delete empty directories.

Using PowerShell to find and delete empty folders

Follow these steps to find empty folders and delete them using PowerShell:

  1. Open the Start menu, type Powershell, right-click, and select Run as administrator.
  2. Type cd /d DriveName:\To\FolderPath in the PowerShell window and press Enter.
  3. To list empty directories, run this command: Get-ChildItem -Directory -Recurse | Where-Object { $_.GetFiles().Count -eq 0 -and $_.GetDirectories().Count -eq 0 } | Select-Object FullName
  4. After reviewing the list, if you decide to delete the empty directories, run this command: Get-ChildItem -Directory -Recurse | Where { $_.GetFiles().Count -eq 0 -and $_.GetDirectories().Count -eq 0 } | Remove-Item -Force
    Windows power shell window with the codes to print and then remove empty folders

This code scans the folders and subdirectories in DriveName:\To\FolderPath and finds empty directories (no files, no subfolders), and deletes them.

Using Windows Explorer to find and delete empty folders

Here’s a step-by-step guide for finding empty folders using Windows Explorer:


  1. Press Win + E to open File Explorer.
  2. Navigate to the drive or folder where you wish to search for empty directories.
  3. Access the View tab and toggle Hidden items from the context menu to make all hidden files visible for the search.
    A screenshot of Windows file explorer showing the steps to show hidden files

  4. Activate the search ribbon by typing a word to activate the search, select Search options, and toggle All subfolders for a complete search.
    A screenshot of Windows file explorer showing the steps to toggle all subfolders in search options

  5. Click the Size option, select Empty (0 KB), and choose Folder under Type.
    Screenshot of Windows File Explorer displaying the search results for 'size:empty' with the size filter options open, showing 'Empty (0 KB)' selected.

  6. Alternatively, enter type:folder size:empty in the search box to locate empty directories.
    Screenshot of Windows File Explorer displaying the search results for 'type:folder' with the type filter options open, showing 'folder' selected.

  7. Delete the folders you want from the search results.
    Result of a search query in windows explorer's search function


While this method is usually effective, it has limitations. For example, it can’t remove folders containing empty or useless Windows files like
desktop.in
, which Windows uses to store custom settings for folder views. Additionally, it struggles with UNICODE characters. If your folders have non-Latin letters in their names, this command doesn’t process them.

Using third-party software to find and delete folders

Third-party software offers a graphical and user-friendly alternative to manual searches in File Explorer or command-line methods. These tools are designed with features in addition to basic deletion. They allow you to delete files selectively and have built-in safety checks to keep you from accidentally removing crucial folders.

For example, system optimizers like CCleaner include disk cleaning and registry repair features that move empty directories and file systems to the Recycle Bin. If you accidentally delete something, use the Restore option to get it back.

Keep your system at peak performance through regular cleanup

With those empty folders out of the way, you’ll notice a speed bump in your Windows computer’s performance. Fewer folders mean faster indexing, which helps your computer find and organize files more efficiently.


Whether gaming, working, or web browsing, a cleaner directory structure makes your experience more enjoyable. Regular maintenance is key to keeping your system running at its best. So, keep up with these tidy-up tasks and happy computing.

Related

How to speed up your computer

Because slowdown can easily ruin your overall user experience



Source link

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *