Skip to content

Instantly share code, notes, and snippets.

@TheSavior
Created February 22, 2013 01:28
Show Gist options
  • Save TheSavior/5010053 to your computer and use it in GitHub Desktop.
Save TheSavior/5010053 to your computer and use it in GitHub Desktop.
Clear music folder of empty folders (or ones with stupid hidden files)
Get-ChildItem –Recurse –Include *.jpg,Desktop.ini,thumbs.db –Force | Remove-Item -force #–whatif
# pulled from http://guyellisrocks.com/powershell/powershell-script-to-remove-empty-directories/
$items = Get-ChildItem -Recurse
foreach($item in $items)
{
if( $item.PSIsContainer )
{
$subitems = Get-ChildItem -Recurse -LiteralPath $item.FullName
if($subitems -eq $null)
{
"Remove item: " + $item.FullName
Remove-Item -LiteralPath $item.FullName
}
$subitems = $null
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment