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.
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:
- Open the Start menu, type cmd, right-click, and select Run as administrator.
- In the Command Prompt window, type cd /d DriveName:\To\FolderPath, and press Enter to open your specified directory.
- 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
- 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”
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:
- Open the Start menu, type Powershell, right-click, and select Run as administrator.
- Type cd /d DriveName:\To\FolderPath in the PowerShell window and press Enter.
- 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
- 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
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:
- Press Win + E to open File Explorer.
- Navigate to the drive or folder where you wish to search for empty directories.
- Access the View tab and toggle Hidden items from the context menu to make all hidden files visible for the search.
- Activate the search ribbon by typing a word to activate the search, select Search options, and toggle All subfolders for a complete search.
- Click the Size option, select Empty (0 KB), and choose Folder under Type.
- Alternatively, enter type:folder size:empty in the search box to locate empty directories.
- Delete the folders you want from the search results.
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.