Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Clear-Host
  2.  
  3. Write-Host "Moving music parent directories to Fermion..."
  4.  
  5. $file = gc "C:\Users\Derrick Liu\Desktop\Played.txt"
  6.  
  7. $destination = "\\ld-fermion\music"
  8.  
  9. foreach ($path in $file)
  10. {
  11.     $lastIndex = $path.lastindexof('\')
  12.    
  13.     $filename = $path.substring($lastIndex)    
  14.     $directory = $path.substring(0, $lastIndex)
  15.     $subDirectory = [regex]::split($directory, "music")[1]
  16.    
  17.     $coalesced = $destination + $subDirectory
  18.    
  19.     if(![IO.Directory]::Exists($coalesced))
  20.     {
  21.         Write-Host "Copying " $directory " to " $coalesced
  22.         cp $directory $coalesced -recurse
  23.     }
  24.     else
  25.     {
  26.         Write-Host "Directory already exists, not copying."
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement