Skip to content

Instantly share code, notes, and snippets.

@alexinnes
Created May 20, 2015 11:25
Show Gist options
  • Save alexinnes/850d2e88a418b6c8765f to your computer and use it in GitHub Desktop.
Save alexinnes/850d2e88a418b6c8765f to your computer and use it in GitHub Desktop.
Finds empty folders and removes them.
#Enter top level location here
$filelocation = ""
#Remove the -whatif at the end if you want it to actually remove the folders
(gci $filelocation -r | ? {$_.PSIsContainer -eq $True}) | ?{$_.GetFileSystemInfos().Count -eq 0} | Remove-Item -verbose -whatif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment