Search and delete empty folders on Windows using PowerShell
After a long time of using the computer (here I'm talking about is the Windows 10 operating system), after installing more software, as well as uninstalling software . often it will leave messages empty folders (these folders are folders containing temporary files or folders left over after you perform software removal).
Although these empty folders usually do not have too much impact on the process of using the computer, leaving too many useless empty folders will also somewhat slow down data access from the hard drive, so I I recommend that you delete them.
Of course you can find and delete them manually, but the reason is that these empty folders are often scattered all over the hard drive, so it is very difficult to delete them manually. not very feasible.
There are also some software to support this work, but if you do not want to use software, there is still a way for you.
In this article, I will show you how to delete empty folders on Windows 10 automatically without using software.
How to find and delete empty folders on Windows 10 using PowerShell
In this article, we will use the PowerShell tool - a tool created by Microsoft with the purpose of replacing the traditional Command Prompt.
If the Command Prompt uses a fairly simple programming language, Powershell with the addition of Windows Scripting Host, VBScript, etc. will give you more rights to intervene in the Windows system more deeply.
However, it is only suitable for IT administrators and professional users, because for most basic users, PowerShell's command lines are quite confusing and confusing, especially it distinguishes both uppercase and lowercase letters in the command.
Perform:
+ Step 1: First, you open Windows PowerShell with Administrator rights by right-clicking on the Start button => and selecting Windows PowerShell (Admin).
Or you can press the Windows + X key combination => and then select Windows PowerShell (Admin) in the Menu that appears.
If the menu that pops up doesn't have PowerShell but is a Command Prompt, it's because you've turned it off in the settings.
To show it again, right-click on the Taskbar => and select Taskbar Settings, in the settings window of this Taskbar => scroll down and turn the switch OFF => to ON in the line:
Replace Command Prompt with Windows PowerShell in the menu when i right-click the start button or press Windows Key + X.
Or another way for those of you who do not want to change the settings is that you can enter the powershell command into the Windows 10 search box (to open the search box you use the Windows + S combination)
=> Then right-click on the Windows PowerShell application in the search results => And select Run as Administrator, you can also run PowerShell with Administrator rights on Windows 10.
+ Step 2: Now copy and paste the command lines below into the Windows Powershell window => and Enter to start searching for empty folders.
Remember to replace the C: in the $SomePath= variable with the path of the drive, or directory where you want to check if it has an empty directory.
The following command:
$SomePath='C:'
Get-ChildItem -Path $SomePath -Recurse -Directory | ForEach-Object -Process {
if ($false -eq $_.GetFileSystemInfos())
{
$_.FullName
}
}
Immediately, a list of multiple directories in the directory you specified in the $SomePath variable will appear.
+ Step 3: Your job now is to access these paths with Windows Explorer (Windows + E) and delete it.
Similarly, if I want to check the Games folder in the D: drive, I will change the above code to: $SomePath='D:Games'…. => then Enter is okay.
With this trick, you don't necessarily have to use Windows PowerShell with Admin rights, but if you run it normally, there will be a few system folders that PowerShell does not have access to to be able to detect empty folders.
Besides, there are still folders that even if you run PowerShell as Administrator, it cannot be detected. Usually these are folders created by the Windows system to ensure operation, so if you find them, they should not be deleted.
Conclude
So I have just instructed you in detail how to find and delete empty folders on Windows 10 without installing any 3rd party software. Hope this article will be useful to you. Good luck !
You should read it
- Delete all empty folders on Android with just one touch
- 7 ways to fix Windows error showing an empty folder even though there are files inside
- Instructions for fixing errors 'Cannot delete folder: The directory is not empty'
- How to delete all empty folders, junk folders on Windows 10
- What is the Windows.old folder and how do you delete it?
- How to install PowerShell 7.0 in Windows 10/8/7
- Delete Files on Mac - Empty Trash or Secure Empty Trash?
- How to delete the Windows.old folder in Windows 11
- 4 ways to delete Windows.old folder on Windows 10 computer
- How to fix errors cannot clean up Trash on Mac
- 7 small tips with folders in Windows
- New Windows 11 problem: Self-created hundreds, thousands of empty folders
Maybe you are interested
How to Enable and Disable Tabs in File Explorer on Windows 11
5 macOS Sequoia Features Not Available on Windows 11
Why does Windows operating system have such a bad reputation?
Quickly fix Unmountable Boot Volume error on Windows 10/11
15 safe software and application download websites for Windows
How to Fix Clipboard History Error in Windows 11 Latest Update