Skip to content

Instantly share code, notes, and snippets.

@cbmeeks
Created December 14, 2012 16:28
Show Gist options
  • Save cbmeeks/4286686 to your computer and use it in GitHub Desktop.
Save cbmeeks/4286686 to your computer and use it in GitHub Desktop.
Cleanup Folders
function Cleanup-Folders($path) {
if($path) {
Get-ChildItem -recurse | Where {$_.PSIsContainer -and @(Get-ChildItem -Lit $_.Fullname -r | Where {!$_.PSIsContainer}).Length -eq 0} | Remove-Item -recurse -whatif
}
}
Cleanup-Folders "c:\temp\blah"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment