How to trace and remove an empty folder in your PC via Powershell

Share this post on:

Have you ever faced a flood of empty folders in your storage? I will show you how to trace and delete empty folders using Windows PowerShell ISE.

1. Run Windows PowerShell ISE as an administrator.
2. Use the command below. You just need to specify the path of the folder you want to search for and delete empty folders. In my case I put as “C:\Users\User\Desktop\Kerja”

$path = 'C:\Users\User\Desktop\Kerja'
Get-ChildItem $path -Recurse -Directory | ForEach-Object {
    If((Get-ChildItem $_.FullName) -eq $null) {
        Remove-Item -Path $_.FullName -Confirm
    }
 }

3. Press Enter and then press Yes to All.

4. Finished.

Loading