Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1.  
  2. $SourceFolder = "D:\Downloads"
  3. $DestinationFolder = "D:\test"
  4. $IncludeFiles = ("*.jpeg","*.jpg")
  5.  
  6. Get-ChildItem $SourceFolder -Recurse -Include $IncludeFiles | Where-Object {$_.LastWriteTime -gt $ChangesStarted} | ForEach-Object {
  7. $PathArray = $_.FullName.Replace($SourceFolder,"").ToString().Split('\')
  8.  
  9. $Folder = $DestinationFolder
  10.  
  11. for ($i=1; $i -lt $PathArray.length-1; $i++) {
  12. $Folder += "\" + $PathArray[$i]
  13. if (!(Test-Path $Folder)) {
  14. New-Item -ItemType directory -Path $Folder
  15. }
  16. }
  17. $NewPath = Join-Path $DestinationFolder $_.FullName.Replace($SourceFolder,"")
  18.  
  19. Copy-Item $_.FullName -Destination $NewPath
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement