感谢您阅读我的帖子和您的建议 :) 场景是,我的桌面内置了一个 HD,我收集了很多年的文件。所以有一天我做了一个外部硬盘的备份,然后我去旅行并继续从我的手机等收集照片。
从那以后,我在桌面上更改了很多文件夹结构,所以我无法比较文件夹/文件 1on1。
目标显然是,将我的外部 HD 上的所有新文件复制到我的内部 HD,都放在一个名为“2SORT”的文件夹中。
我找到了一个更快的 compare-object 版本(见评论),但结果不正确,它会复制很多已经存在的文件。
这是我在 Powershell 中得到的:
cls
$path_desktop = 'C:\Files\Media\Bilder'
$path_external = 'E:\Bilder'
$path_destination = 'C:\Files\Media\Bilder\2SORT'
$ref = Get-ChildItem -path $path_desktop -Recurse -File
$com = Get-ChildItem -path $path_external -Recurse -File
$file_Diffs = Compare-Object -ReferenceObject $ref -DifferenceObject $com | Where { $_.SideIndicator -eq '=>' }
$file_Diffs |
foreach {
$copyParams = @{}
$copyParams.Path = $_.InputObject.FullName
$copyParams.Destination = "$path_destination\" + $_.InputObject.Name
copy-Item @copyParams -force -PassThru | Write-Host
}