Saturday, June 22, 2024
HomePowershellSearch and delete empty Folders – SID-500.COM

Search and delete empty Folders – SID-500.COM


Massive Knowledge? Ache? In search of empty folders and need to delete them? On this submit I present you easy methods to proceed to search out and delete empty folders.

Open PowerShell, ISE or VS Code.

Warning: For those who proceed, all empty folders can be deleted with none warning.

Specify the foundation folder in line 1. In my instance that is C:Knowledge. Then execute the PowerShell code.

All subfolders that are empty can be scanned and deleted with out affirmation.

# Folder empty, then take away them


Get-ChildItem $path -Recurse -Listing | ForEach-Object {
    If((Get-ChildItem $_.FullName) -eq $null) {
        Take away-Merchandise -Path $_.FullName -Verify:$false -Verbose

The verbose parameter ensures that you would be able to see every thing that’s taking place.

Mission achieved.

Revealed by Patrick Gruenauer

Microsoft MVP on PowerShell [2018-2023], IT-Coach, IT-Marketing consultant, MCSE: Cloud Platform and Infrastructure, Cisco Licensed Academy Teacher.



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments