Я пытаюсь пройти через каталог и скопировать его с A на B. Это можно сделать со следующим:
Copy-Item C:\MyTest C:\MyTest2 –recurse
Я хочу иметь возможность копировать только новые файлы (те, которые существуют в src, но не dest), а также копировать только файлы, которые могут быть изменены на основе проверки CRC, а не штампа даты и времени.
$file = "c:\scripts"
param
(
$file
)
$algo = [System.Security.Cryptography.HashAlgorithm]::Create("MD5")
$stream = New-Object System.IO.FileStream($file, [System.IO.FileMode]::Open)
$md5StringBuilder = New-Object System.Text.StringBuilder
$algo.ComputeHash($stream) | `
% { [void] $md5StringBuilder.Append($_.ToString("x2")) }
$md5StringBuilder.ToString()
$stream.Dispose()
Этот код дает мне проверку CRC на конкретный файл... Я просто не уверен, как собрать два сценария, чтобы действительно дать мне то, что мне нужно. Я также не знаю, действительно ли проверка CRC на самом деле является правильным способом.
Есть ли у кого-нибудь проницательность?