Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Jaykul/11a91a35e9d504077b4112056573239c to your computer and use it in GitHub Desktop.
Save Jaykul/11a91a35e9d504077b4112056573239c to your computer and use it in GitHub Desktop.
param(
$Source = "c:\users\USER1\desktop\test\folder1",
$Destination = "c:\users\USER1\desktop\test\folder2"
)
$Sources = Get-ChildItem $Source -recurse -depth 4 | Where-Object {$_.name -like "*``, *`` *``(*2016)"} | Select-Object -ExpandProperty FullName
Push-Location $Source
foreach($SourcePath in $Sources) {
$DestPath = Join-Path $Destination (Resolve-Path $SourcePath -Relative)
robocopy $SourcePath $DestPath /xo /e
}
Pop-Location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment