Guest User

Untitled

a guest
Feb 18th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. Get-ChildItem $SourceFolder -Include $ExtArray -Recurse | forEach {
  2. ## Remove the original root folder
  3.  
  4. $split = $_.Fullname -split '\'
  5.  
  6. $DestFile = $split[1..($split.Length - 1)] -join ''
  7.  
  8. ## Build the new destination file path
  9.  
  10. $DestFile = "C:DestinationFolder$DestFile"
  11.  
  12. ## Copy-Item won't create the folder structure so we have to
  13.  
  14. ## create a blank file and then overwrite it
  15.  
  16. $null = New-Item -Path $DestFile -Type File -Force
  17.  
  18. Copy-Item -Path $_.FullName -Destination $DestFile -Force
  19.  
  20. }
Add Comment
Please, Sign In to add comment