App to find empty folders on a drive


Sigurd

Well-known member
Member
VIP
Local time
7:02 PM
Posts
271
OS
Windows 11
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

System One

  • OS
    Windows 11
    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
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 Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 [rev. 3447]
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical Keyboard with Cherry MX Clears
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical Keyboard - Cherry MX Clear
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 Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 [rev. 3447]
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical Keyboard with Cherry MX Clears
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical Keyboard - Cherry MX Clear
Back
Top Bottom