Created
February 22, 2013 01:28
-
-
Save elicwhite/5010053 to your computer and use it in GitHub Desktop.
Clear music folder of empty folders (or ones with stupid hidden files)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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