私は PowerShell に慣れていませんが、学習曲線を押し進めようと決心しており、追加の支援が必要です。
Compare-Object を使用して、サブディレクトリ間でファイルを比較しています。これは機能し、すべての相違点のリストを返します。
違い (ファイル名) を配列/変数 (?) に入力し、ファイル名を参照してファイルを指定された場所にコピーする必要があります。
[string] $CopyFromPath = "C:\folder"
[string] $TargetCopyPath = "D:\folder"
Compare-Object -ReferenceObject $SourceFileSet -DifferenceObject ($TargetParentPath + $child) |
Select @{
n = "$($child.ToUpper()) (Missing data in $TargetCopyPath)"
e = {$_.InputObject}
} | ft
foreach($f in $MissingFile) {
Copy-Item -Path ($CopyFromPath + "\" + $MissingFile) -Destination $TargetCopyPath
}
それはおそらく非常に単純であり、私のアプローチはやり過ぎかもしれませんが、どんな意見でも大歓迎です。
ありがとう!