Move folders (from txt file) to another drive with dir structure

PHOTO EMBED

Thu Jun 20 2024 09:12:43 GMT+0000 (Coordinated Universal Time)

Saved by @baamn #powershell

$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}

      }
    
  
content_copyCOPY

https://community.spiceworks.com/t/powershell-move-folders-from-txt-file-to-another-drive-with-dir-structure/715354