title: Find duplicate files with different extensions using python
body: <p><strong>SOLUTION</strong> see EDIT at bottom of this comment.</p>
  
  <p><strong>PROBLEM:</strong> I have a directory with a heap of images, named something like below:</p>
  
  <ul>
  <li>image001.nef</li>
  <li>image002.nef</li>
  <li>image003.nef</li>
  <li><strong>image003 - 20170609.jpg</strong></li>
  <li>image004.nef</li>
  <li>image005.nef</li>
  <li>image006 - 20170609.nef</li>
  <li>image007.nef</li>
  <li><strong>image007 - 20170609.jpg</strong></li>
  <li><strong>image008.jpg</strong></li>
  <li>image008 - 20170609.nef</li>
  </ul>
  
  <p>I want to find all images that are a duplicate base name (like imageXXX) AND the extension is JPG</p>
  
  <p>So from my above list, there are only three items that match the criteria to delete (i have <strong>bold</strong> those items). </p>
  
  <p>I have 2,500 images so a pythonic way is desirable to me manually going through.</p>
  
  <p>I am having a hard time finding an example script to use, all the ones I have found are checking the HASH or something, which I don't believe is useful as the images are indeed similar, but not identical.</p>
  
  <p>Cheers</p>
  
  <p>EDIT:
  thanks to dawg I was able to get the output I desire... here is the final code that worked for me:</p>
  
  <pre><code>import os
  
  directory = r'C:\temp'
  out_directory = r'C:\temp\temp_usa_photos'
  fns = os.listdir(directory)
  
  
  ref_nef = {fn[0:15] for fn in fns if fn.upper().endswith('.NEF')}
  
  print ref_nef
  
  out_list = filter(lambda e: e[0:15] in ref_nef, [fn for fn in fns if fn.upper().endswith('.JPG')])
  
  print out_list
  
  for f in out_list:
      input_file = os.path.join(directory, f)
      output_file = os.path.join(out_directory, f)
      os.rename(input_file, output_file)
  </code></pre>