Best way to do a hash compare of 2 folders


  1. Posts : 267
    Win 10 Pro x64
       #1

    Best way to do a hash compare of 2 folders


    So I have two folders. The first folder has duplicate files that exist in the second folder. The problem is that in the second folder, the files are named very differently. Is there a way to do a hash compare of both folders, and then for it to tell me which files there is duplicates for in both folders, and which files there are not?
      My Computer


  2. Posts : 810
    Win10
       #2

    Here's a quick Powershell script:

    Code:
    function DoFolderHash([string]$folder1, [string]$folder2)
    {
      $hashes1 = Get-ChildItem -Path "$folder1" -Recurse | Get-FileHash
      $hashes2 = Get-ChildItem -Path "$folder2" -Recurse | Get-FileHash
      $files = $hashes1.Path + $hashes2.Path
      ""
      "Identical files:"
      foreach($h1 in $hashes1)
      {
        foreach($h2 in $hashes2)
        {
          if($h1.Hash -eq $h2.Hash)
          {
            $h1.Path + " == " + $h2.Path
            $files = $files -ne $h1.Path
            $files = $files -ne $h2.Path
          }
        }
      }
      ""
      "Unique files:"
      $files
      ""
    }
    Copy+paste it into a Powershell window and run DoFolderHash <Folder 1> <Folder 2>

    Code:
    PS C:\Users\Me> DoFolderHash "c:\temp\1" "c:\temp\2"
    
    Identical files:
    C:\temp\1\HxD32.exe == C:\temp\2\a
    C:\temp\1\HxD32.exe == C:\temp\2\e
    C:\temp\1\HxD64.exe == C:\temp\2\g
    C:\temp\1\readme.txt == C:\temp\2\f
    C:\temp\1\Settings\HxD Hex Editor.ini == C:\temp\2\b
    C:\temp\1\Settings\HxD Hex Editor.lang == C:\temp\2\c
    
    Unique files:
    C:\temp\1\changelog.txt
    C:\temp\1\license.txt
    C:\temp\2\d
    C:\temp\2\h
    
    PS C:\Users\Me>
      My Computer

  3. dalchina's Avatar
    Posts : 30,067
    Win 10 Pro (1903)
       #3

    This program can..
    Best way to do a hash compare of 2 folders-1.jpg

    - that's shareware..

    Free:
    Verify files in two directories with Checksum Compare - gHacks Tech News
    - but doesn't recurse if folders are nested.

    Screenshots of Quickhash running on Windows, Linux and Apple Mac OSX | QuickHash GUI
    - this shows a screenshot of contents of two folders listed and compared as one of its functions.
      My Computers


  4. Posts : 267
    Win 10 Pro x64
    Thread Starter
       #4

    Thanks all! I'll check both of these out.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 08:34.
Find Us




Windows 10 Forums