1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$sourceFolders = @( "C:\Users\xxx\Desktop\a", "C:\Users\xxx\Desktop\aaa" ) $targetFolder = Join-Path "C:\Users\xxx\Desktop\x" (Get-Date).DayOfWeek.value__ if (Test-Path $targetFolder) { Remove-Item $targetFolder -Recurse -Force } New-Item -ItemType Directory -Path $targetFolder | Out-Null foreach ($sourceFolder in $sourceFolders) { if (!(Test-Path $sourceFolder)) { continue } $backupFolder = Join-Path $targetFolder (Split-Path $sourceFolder -Leaf) New-Item -ItemType Directory -Path $backupFolder | Out-Null Copy-Item $sourceFolder\* $backupFolder -Recurse -Force } |