App to find empty folders on a drive


Sigurd

Well-known member
Member
VIP
Local time
12:53 AM
Posts
500
OS
Windows 11 - Updated automatically
I have tried various ways to do this without success. I won't go into all the ways. Suffice to say they either don't work, are too old, or part f an expensive app with functions I don't need.
Any suggestions appreciated.
 

My Computer My Computer

At a glance

Windows 11 - Updated automaticallyIntel i7 12700K Twelve Core 3.6GhzCorsair 32Gb Vengeance RAM
OS
Windows 11 - Updated automatically
Computer type
PC/Desktop
Manufacturer/Model
Updated Chillblast
CPU
Intel i7 12700K Twelve Core 3.6Ghz
Motherboard
MSI PRO Z690-A DDR4 Motherboard
Memory
Corsair 32Gb Vengeance RAM
Cooling
Air cooled
Internet Speed
72Mb down, 18Mb up
Browser
Chrome
Antivirus
Avast
If you're comfortable with PowerShell, this would clean out the user's Temp directory, for example. Run it as-is to see what would be removed; take out the -WhatIf to actually remove things.

Powershell:
function Remove-EmptyFolders
{
    param
    (
        [string]$Path
    )

    if (Test-Path $Path)
    {
        Get-ChildItem -Path $Path -Force -Directory | ForEach-Object { Remove-EmptyFolders $_.FullName }

        Get-ChildItem $Path -Force | Measure-Object |
        ForEach-Object {
            if ($_.Count -eq 0)
            {
                Remove-Item -Path $Path -ErrorAction SilentlyContinue -WhatIf
            }
        }
    }
}

Remove-EmptyFolders -Path $env:Temp
 

My Computer My Computer

At a glance

Windows 11 Enterprise 25H2
OS
Windows 11 Enterprise 25H2
This seems to be accurate if you're using Everything, but remember it's only as accurate as the Everything index.

Background info here and here.

Code:
"C:\Some\Path\Here" childcount:=0
 

My Computer My Computer

At a glance

Windows 11 Enterprise 25H2
OS
Windows 11 Enterprise 25H2
Back
Top Bottom