$parent = "C:\Users\user\Desktop\derp"
$pl = $parent.Length
$dest = "C:\Users\user\Desktop\test"
$empty = get-childitem $parent -recurse |
Where-Object { $_.PSIsContainer } |
Where-Object { $_.GetFiles().Count -eq 0 } |
Where-Object { $_.GetDirectories().Count -eq 0 } |
ForEach-Object { $_.FullName }
foreach ($item in $empty) {
Write-Host $item
$object= Get-Item $item
if($object.parent.fullname.length -gt $pl){
$OParentPath = $object.FullName
$last = $OParentPath.Substring($pl)
$newDest = $dest+$last
mkdir -Path $newDest
Remove-Item $item
}
Else{Move-Item $item -Destination $dest}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter