We stay in occasions of Huge Information. An excessive amount of knowledge in too quick a time. You will have empty folders in your surroundings and if you wish to seek for them and delete them then you might be on the proper place. We are going to do exactly that.
Run this little script beneath to take away all empty folders.
On the prime you want to specify the trail to the foundation folder. In my case that is C:Information. You’ll be requested to verify the deletion.
# Get a listing of all folders
$rootfolder = "C:Information"
$folders = Get-ChildItem -Path $rootfolder -Listing -Recurse
# Filter out the empty folders
$emptyFolders = $folders | The place-Object {$_.GetFileSystemInfos().Depend -eq 0}
# Delete the empty folders
$emptyFolders | Take away-Merchandise -Power -Verbose
And right here is the code in Motion.
We’ve got now cleaned up a bit. That’s good.
Revealed by