title: How to match similar filenames and rename so that diff tools like Beyond Compare see them as a pair to perform a binary comparison?
body: <p>I'm looking for the best approach to comparing files that I believe are identical but which have different filenames. Comparison tools like BeyondCompare are great but they don't yet handle different filenames - when comparing files in separate folders they attempt comparisons with the files that have the same name on either side.</p>
  
  <p>(I don't work for or have a financial interest in BeyondCompare, but I use the tool a lot and find it has some great features).</p>
  
  <p>There is MindGems Fast Duplicate File Finder for matching files in any location throughout several folder trees that have different names but this is based on CRC checks I believe, I am using this tool but I am only gradually trusting it, so far no faults but don't trust it as much as BeyondCompare yet. BeyondCompare offers the complete piece of mind of doing a full binary compare on the file.</p>
  
  <p>In my case the files tend to have similar names, the difference being ordering of the words, punctuation, case differences and not all words present. So it's not easy to use a regex filter to match the files that some diff tools like Beyond Compare already provide because the file substrings can be out of order.</p>
  
  <p>I'm looking for a way to match similar filenames before renaming the files to be the same and then 'feeding' them to a tool like BeyondCompare. Solutions could be scripts or perhaps in the form of an application.</p>
  
  <p>At the moment I have an idea for an algorithm (to implement in Perl) to match the filenames to suit my problem whereby the filenames are similar as described above.</p>
  
  <p>Can you suggest something better or a completely different approach?</p>
  
  <ol>
  <li><p>Find a list of files with the exact same filesize</p></li>
  <li><p>Make a hash of alphanumeric substrings from first file, using
  non-alphanumeric characters or space as delimiter</p></li>
  <li><p>Make a hash of alphanumeric substrings from second file, using
  non-alphanumeric characters or space as delimiter</p></li>
  <li><p>Match occurrences</p></li>
  <li><p>Find which file has the highest number of substrings.</p></li>
  <li><p>Calculate a percentage score for the comparison on the pair based on
  number of matches divided by the highest number of substrings.</p></li>
  <li><p>Repeat comparison for each file with every other file with the exact
  file size</p></li>
  <li><p>sort the pair comparisons by percentage score to get suggestions of
  files to compare. </p></li>
  <li><p>Rename one file in the pair so that it is the same as the other. Place in separate folders.</p></li>
  <li><p>Run a comparison tool like BeyondCompare with the files, folder comparison mode.</p></li>
  </ol>