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
- 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
May be interested
- Some tips to increase FPS while playing games on laptopsmaintaining a high fps (fps) not only gives you a more complete graphical experience, but also gives you a significant competitive advantage in the game.
- A simple, free trick that can make your computer 'smooth' like it was when you first bought itover time, the computer will slow down. part of that is, of course, due to aging hardware, but for most people, the more common cause is poor operating system maintenance.
- 7 tips to help secure online meetings on Zoomto create a seamless and engaging online meeting experience on zoom, you first need to make sure you're providing a controlled and secure environment. here are some key ways you can secure your zoom online meeting.
- Steps to make rain in Photoshop look lifelike with just a few tapsthis article will show you how to create realistic rain in photoshop with just a few simple steps, helping you to have photos that look extremely attractive and romantic.
- Told you 5 shortcuts with the Windows button on your computer that are extremely usefultoday's article i will introduce to you 5 extremely useful shortcuts with the windows button on your computer, making it a lot more convenient for you when using a windows computer.
- How to check the 'clean' level of a file before using it on a Windows computerdownloading files from the internet or email to your computer is the most common act of infecting viruses and malware today.