0

some times after i copy a folder to onother drive i like to md5 hash compare to make sure they are identical i use the command bellow i run it on the source then on the copy

Get-ChildItem -Path "source" -Recurse -File |

Get-FileHash -Algorithm MD5 |

Export-Csv -Path 'new source\MediaHashes1.csv' -UseCulture -NoTypeInformation

what i want to improve is

i want powershell to hash md5 check the 2 folders compare the results and then tell me if they are identical or not in a single command

Mariah242
  • 47
  • 1
  • 7
  • What you propose is not robust. There is a small probability that two items that was not identical will give same hash. So without comparing actual files your code may not work. – jdweng Mar 31 '23 at 11:03
  • @jdweng Although technically correct, I don't think that's useful to try and take into account here. `Get-FileHash` defaults to SHA256, the likelihood of a collision occurring is literally 1 in a trillion trillion trillion trillion trillion trillions (to my knowledge no known collisions have been identified yet) – Mathias R. Jessen Mar 31 '23 at 11:30
  • Related: [Powershell Speed: How to speed up ForEach-Object MD5/hash check](https://stackoverflow.com/a/59916692/1701026) – iRon Mar 31 '23 at 12:21
  • why not use Robocopy /mir ? – Dom Apr 02 '23 at 19:54

0 Answers0