- Free software to delete Empty folders in Windows 10
- Delete empty folders & directories
- 1] Find Empty Files and Folder
- 2] Remove Empty Directories
- 3] Empty Folder Cleaner
- 4] Empty Folder Nuker
- 5] FMS Empty Folder Remover
- 6] Fast Empty Folder Finder
- How to Delete Empty files (0 byte) in Windows?
- Find and/or delete empty (0 byte) files in Windows:
- Find and delete 0-byte files recursively in a folder tree
- 1. Using the “Find Empty Files-n-Folders” utility
- 2. Using Windows Search
- 3. Using Command Prompt
- Find and delete 0-byte files having a specific file extension
- Create a Batch file
- What does the above command do?
- 4. Using PowerShell
- List empty (0 KB) files
- Delete empty (0 KB) files
- 5. Using VBScript
- Usage
- 6. Using DelEmpty.exe
- How to Remove Empty Folders Automatically in Windows
- Contents
- How to Find and Remove Empty Folders in Windows?
- 1. Remove empty folders using the “Find Empty Files-n-Folders” utility
- 2. Remove empty folders using “for” and “rd” commands
- How does the command work
- Find empty folders, but don’t delete
- 3. Find and remove empty folders using Robocopy
- Want to find empty folders but not delete them?
- 4. Find and Remove empty folders using PowerShell
- Find empty folders, but don’t want to delete them?
- 5. Find and Remove empty folders using Windows Scripting
- 6. Find and Remove empty folders using DelEmpty.exe
Free software to delete Empty folders in Windows 10
Someone asked me – Is it safe to delete empty folders, made me search for some good empty folder deleting freeware. While you would make no real space savings as they occupy 0 bytes, if it is just good house-keeping you are looking for, it may be a good idea.
Delete empty folders & directories
There are several free software available to delete empty folders. Here are some I came across:
1] Find Empty Files and Folder
Find Empty Files and Folder scans your entire drive, analyze the folders in it, and display all the empty directories if found. Once the list is ready, hit the Delete button and watch the files go into extinction. Folders that can’t be deleted from this tool might include hidden files or be connected to a program that relies on them. So, it’s better not to delete them. It also allows you to delete 0-byte files.
2] Remove Empty Directories
It shows the empty directories before deleting them, supports multiple delete modes (including Delete to recycle bin), allows white and blacklisting of directories by using filter lists, and can detect directories with empty files as empty. It allows you to ignore certain directories and offers various other options. It also identifies Protected folders.
Remove Empty Directories lets you find and delete empty folders and directories right from the context menu itself. This is quite convenient in my opinion. You have to open its Settings and click the Integrate button to integrate the program’s entry into the Explorer context menu. Get it here.
3] Empty Folder Cleaner
The free tool lets you delete empty folders permanently, delete them to the recycle bin, or store as a backup, compressed in a zip file. Moreover, if required each deletion can be undone.
4] Empty Folder Nuker
This one is a portable app that finds and deletes all empty folders (with empty sub-folders) starting from a base folder of your choice. It allows you to delete the files to the Recycle Bin where available. A plus here is that it allows Shell integration, thereby letting you right-click on any folder in Windows Explorer and find empty folders within it.
5] FMS Empty Folder Remover
Here is another freeware tool which is a useful application that will enable you to easily get rid of unwanted directories. This lightweight tool scans a source folder and instantly identifies the empty directories within. Go here to get it.
6] Fast Empty Folder Finder
It finds empty folders quickly, shows you a preview of its contents, and gives you the option to delete those folders to the Recycle Bin or directly. Download it here.
As a matter of abundant precaution, for the first time, I’d suggest you empty your Recycle Bin, create a system restore point and then, if the software, allows you to, opt to delete the empty folders to the Recycle Bin, rather than just directly deleting them.
Date: July 30, 2020 Tags: Folder, Freeware
How to Delete Empty files (0 byte) in Windows?
Some applications create empty 0-byte files in their data folders and fail to clear them up. Over time, if you see many zero-byte files in a folder hierarchy, here are some methods to find all those 0-byte files and delete them.
Find and/or delete empty (0 byte) files in Windows:
Find and delete 0-byte files recursively in a folder tree
It’s important to note that deleting 0-byte files arbitrarily can be problematic sometimes, as some applications may need them as a placeholder or for some other reason. If you’re sure that you don’t need any 0-byte files in a folder path and want to delete them all, follow one of the methods below.
Let’s start with a neat 3rd party freeware GUI tool, and then cover the native methods next.
1. Using the “Find Empty Files-n-Folders” utility
Find Empty Files-n-Folders is an excellent tool that can find and delete empty files (0-byte) and empty folders recursively under a folder tree.
Download Find Empty Files-n-Folders (600KB installer) from Ashisoft.com.
Select the folder and click Scan Now.
The tool will list empty files and folders in separate tabs.
From the Empty Files tab, click Mark all Files and then click Delete Files.
Similarly, to delete the 0-byte files in the selected folder tree, click on the Empty Files tab.
Ashisoft.com has other awesome tools that you can check out!
2. Using Windows Search
Windows Search allows you to list all 0-byte files using the size: query operator.
Open the folder where you want to find or delete empty files.
In the search box, type size:empty or size:0 KB
To filter the results by a file extension (e.g., javascript files → extension .js ), use the following Advance Query Syntax (AQS):
3. Using Command Prompt
To list all 0-byte (0 KB) files is a folder and sub-folders recursively and output the names to a file, use the following command.
Note that you’ll need to run the command from the folder where you want to find or delete empty (0 KB) files.
Alternately, you can include the target folder path in the for command so that you don’t have to change the directory in the console window. Example:
That way, you don’t have to switch over to that particular folder in Command Prompt
The complete list of 0-byte files output is written to the file named 0byte-files.txt on the D:\ drive.
To delete the files, you’d use the del command instead of echo .
or mention the target folder path in the command itself:
Find and delete 0-byte files having a specific file extension
In the above examples, you can even filter by file extension. For instance, to delete 0-byte .txt files, you’d use *.txt instead of *.* or *
or with mentioning the folder path:
That would delete all the empty .txt files from the current folder and sub-folders, or in the specified folder tree recursively.
Create a Batch file
If you’d like to make a batch file to find and list empty files and output the results to a text file, here is one:
Save the above contents as find-empty-files.bat .
To delete empty files rather than outputting the list of files, use this batch file:
To run the batch file against a folder recursively, you’d use the following syntax:
What does the above command do?
- for /r %F in (*) iterates files recursively in the mentioned folder and subfolders.
- if %
zF==0 checks if the iterated file is a 0-byte file
del %%
fA delete the 0-byte file
4. Using PowerShell
Start PowerShell.exe and use one of the following methods:
List empty (0 KB) files
To get the list of 0-byte files under a folder tree, use this command-line syntax:
To output the list to a file:
To output the list to grid view:
To list only a specific file type (e.g., .bmp ) :
Delete empty (0 KB) files
To delete all the 0-byte files under a folder tree, use this command-line syntax:
To delete 0-byte files having a specific extension (e.g., .bmp )
5. Using VBScript
The following VBScript clears empty (0-byte) files in a folder tree recursively.
Copy the following code to Notepad and save it as del-zero-byte-files.vbs
Usage
To run the script against a folder, you can use wscript.exe or cscript.exe, like below:
CScript.exe shows the outputs to the console window. That means you’ll need to run it from a Command Prompt window to see the output.
WScript.exe shows the outputs in the GUI.
via the Send To menu
You can create a shortcut to the script in your SendTo folder and name it as Delete 0-byte Files. Prefix wscript.exe in the shortcut properties target field.
Then, right-click on a folder where you want to delete empty files in the folder tree recursively → click Send To → click Delete 0-byte Files in the Send To menu.
You’ll see the list of empty files deleted and the total, and files which couldn’t be deleted with the respective error codes displayed.
6. Using DelEmpty.exe
DelEmpty.exe is a console tool from IntelliAdmin that can delete empty directories recursively. This program can also swiftly delete the empty 0-byte files recursively.
The following is the command-line syntax for the program:
Argument | Description |
-f | Delete empty (0-byte) files |
-d | Delete empty directories |
-v | Verbose mode |
-c | Confirm mode (Shows what was deleted) |
-s | Include sub-directories (traverse subfolders) |
-l | List what would be deleted (will not delete) |
-y | Delete without (y/n) prompt |
Example 1: To list the empty files under a directory and its subdirectories, I used the following command-line syntax:
The above command shows the list of empty folders, but will not delete them since the -l (list only) switch is used.
For folder names containing space(s) — e.g., Mozilla Firefox , be sure to include the double-quotes around the path.
Example 2: To delete the empty files in a folder and subfolders, I ran the same command-line but without the -l switch:
Do you know any other utility that can traverse sub-folders and delete empty files? Let’s know your comments.
How to Remove Empty Folders Automatically in Windows
Over time, hundreds of empty folders and junk files may take up your hard disk. While the junk files occupy disk space and can be cleaned up using Disk Cleanup or Storage settings, the empty directories remain.
The empty folders don’t take up disk space, but to organize your data better, you may want to prune them every once in a while.
This article discusses different methods to find and remove empty folders on your computer.
Contents
How to Find and Remove Empty Folders in Windows?
An empty folder or directory is one that has no file or sub-directory in it. Empty folders don’t take any disk space, but too many of them can be a nuisance. To find and remove them, use one of the methods below.
Important: Running an automated tool or batch file to delete empty folders in the entire system drive recursively is usually not recommended. This is because some programs may fail to work and throw a bizarre error when it finds an essential folder missing. As always, the standard warning applies. Be sure to have appropriate backups, preferably on an external drive, before manipulating the file system or the Windows registry.
Let’s start with a neat GUI tool, followed by native command-line and scripting methods.
1. Remove empty folders using the “Find Empty Files-n-Folders” utility
Find Empty Files-n-Folders is an excellent tool that can find and delete empty files (0-byte) and empty folders recursively under a folder tree.
- Download Find Empty Files-n-Folders (600KB installer) from Ashisoft.com.
- Select the folder and click Scan Now.
The tool will list empty files and folders in separate tabs.
Click Mark all Folders and then click Delete Folders.
Similarly, if you want to delete the 0-byte files in the selected folder tree, click on the Empty Files tab.
Ashisoft.com has other awesome tools that you can check out!
2. Remove empty folders using “for” and “rd” commands
You can use the Command Prompt internal commands for and rd to enumerate the list of folders and delete the empty ones.
- Press & hold the Shift key, right-click on a folder and click Open command window here. This opens Command Prompt at the current folder location, which can also verify in the console.
This deletes all the empty directories across sub-directories from the base folder path, including nested empty folders.
If you’re going to use the above command in a batch file, then replace %i with %%i .
Important: The above command won’t delete folders with foreign characters — e.g., 蜍穂. You may want to check out DelEmpty.exe (covered in this article) or other methods to delete folders with Unicode characters.
The above command-line is courtesy of Raymond Chen of Microsoft, via his blog The Old New Thing. In this post, Raymond’s command-line has been slightly modified so that it also deletes folder names containing space(s).
How does the command work
The above command lists all the sub-directories (recursively) in the current base path and sorts the list ( sort /r ) in reverse order. The reverse order sort is to make sure that the enumeration is done bottom-up. This is important for deleting empty directories, as you have to remove the subdirectories before removing the parent.
Then it attempts to remove the list of directories (in reverse sort order) using the RD command. If a directory is not empty, it proceeds on to the next directory and so on. The 2>NUL command ensures that the “directory not empty” output text is suppressed.
The only disadvantage of the above method is that it’s not helpful if you want to find empty folders without deleting them. If you want to find the list of empty folders, use the command-line in the paragraph below, or follow any other method described in this article.
Find empty folders, but don’t delete
To only find the empty folders without deleting them, use this command-line syntax:
It shows you the output containing the list of empty directories.
Let’s say you have empty nested folders like this:
Running the above command lists only the deep most empty folder → 4 . Technically, it’s correct because a folder can’t be considered empty if a sub-folder or a file exists in it.
3. Find and remove empty folders using Robocopy
Robocopy is a powerful built-in file copy tool that has a lot of advanced features. We’ve covered Robocopy in the article Compare the Contents of Two Folders in Windows.
Let’s assume you have a folder named cars , which contains several sub-folders, of which some are empty. We’re going to delete the empty ones using Robocopy.
The trick here is to use the Robocopy move command, passing the exact same folder path for both “source” as well as “destination.”
- Open a Command Prompt window.
- Type the following command and press ENTER :
The most important thing to note here is that the source and destination paths are (deliberately) the same. The /S parameter instructs Robocopy not to move empty folders to the “destination” path. As we’ve mentioned the same paths for source and destination, Robocopy will delete the empty folders due to the /S switch.
The empty folders in the chosen path are now cleared.
Want to find empty folders but not delete them?
You can use the /L (list-only) command-line argument with Robocopy so that it only carries out a dry-run instead of performing the actual copy/move operation.
/L :: List only – don’t copy, timestamp, or delete any files.
/MOVE :: MOVE files AND dirs (delete from source after copying).
/S :: copy Subdirectories, but not empty ones.
You can see the number of files in a column hear the folder path. The 0 s mean that those folders have no files.
Let’s put this command to a real test!
My %APPDATA% folder is full of empty folders added by obsolete programs.
Before the cleanup, the Appdata\Roaming folder had 681 folders, as seen in the folder properties.
I opened the Command Prompt and ran the following command:
Note: %appdata% environment variable translates to C:\Users\
It has successfully removed 94 empty folders in my %APPDATA% folder and sub-folders.
Editor’s note: In the command-line output below the statistics section, the following error appeared:
Because we’ve instructed Robocopy to move ( /MOVE ) the %APPDATA% directory, the tool was trying to clean up the “source” folder after “moving” it to the destination. It couldn’t, as %APPDATA% is a special folder. The error doesn’t occur when used a directory path that’s not a special folder. As everything went on fine, I simply ignored the (trivial) error.
4. Find and Remove empty folders using PowerShell
The following PowerShell command-line deletes empty folders located under the specified base folder recursively.
- Start PowerShell and type the following command:
Replace “folderpath” with the base folder location. For example, I’m specifying the Roaming folder here:
This deletes all the empty sub-folders under my %appdata% folder recursively and doesn’t show any output unless it encounters any error(s).
Note that the above PowerShell command clears only the last level of the empty nested folder. For example, let’s say you have empty nested folders like this:
Running the above command clears the deep most empty folder → 4 . Rerunning the script will clear another level of a nested folder ( 3 ), and so forth.
You can use the PowerShell script at Svendsen Tech PowerShell Wiki to work with nested folders.
Alternately, you can use the next method, a Windows Scripting solution, to clear all empty folders, including nested ones, recursively.
Find empty folders, but don’t want to delete them?
Want to get the list of empty folders, but don’t want to delete them? Use this command-line example instead:
The command outputs the list of empty folders with full paths to a grid view control.
Tip: In the grid view, you can select all and copy the selection by pressing Ctrl + C
It’s a good idea to preview the list before running the command to delete the folders.
5. Find and Remove empty folders using Windows Scripting
Microsoft employee Jeremy Jameson wrote a VBScript that deletes empty folders recursively. I’ve added more lines in the script to force delete empty read-only directories, output the aggregated list of empty folders. It also outputs the list of empty folders that could not be deleted, along with the corresponding error description.
The script is capable of deleting nested empty directories across sub-folders.
Optionally, you may rename the script file accordingly, let’s say delempty.vbs, and move it to the C:\Windows folder.
You can run the script using two ways:
via Command Prompt, by running:
via GUI, by running:
via the Send To menu
You can create a shortcut to the script in your SendTo folder and name it Delete Empty Folders.
Then, right-click on a folder where you want to delete empty sub-folders recursively → click Send To → click Delete Empty Folders in the Send To menu.
You’ll see the list of empty folders deleted and the total, and folders that couldn’t be deleted with the respective error codes displayed.
6. Find and Remove empty folders using DelEmpty.exe
DelEmpty.exe is a console tool from IntelliAdmin that can delete empty directories recursively. This program can also swiftly delete the empty 0-byte files recursively.
The following is the command-line syntax for the program:
Argument | Description |
-f | Delete empty (0-byte) files |
-d | Delete empty directories |
-v | Verbose mode |
-c | Confirm mode (Shows what was deleted) |
-s | Include sub-directories (traverse subfolders) |
-l | List what would be deleted (will not delete) |
-y | Delete without (y/n) prompt |
Example 1: To list the empty folders under the Mozilla directory under AppData, I used the following command-line:
The above command shows the list of empty folders, but will not delete them since the -l (list only) switch is used.
For folder names containing space(s) — e.g., Mozilla Firefox , be sure to include the double-quotes around the path.
Example 2: To delete the empty folders under the Mozilla directory under %AppData% , I run the same command-line but without the -l switch:
The program traverses through every subfolder and deletes the empty folders. Nested empty folders are removed too. For example, if you were looking to remove empty directories from this structure:
After the EmptyFolder1 and EmptyFolder2 folders are removed, Folder 2 is empty as well — and it will also be removed. Also, DelEmpty.exe is capable of removing folders with unicode/foreign characters as well — e.g., 蜍穂
If you know any other methods to remove empty folders in Windows, let’s know that in the comments section below.