Code to automatically search for duplicate files?

This is something I'd like to do:

  1. Select folders by highlighting them - they can be across different partitions or different directories within the same partition.

  2. Click a button with code that tells DOpus to check to see if there are duplicate files and then hides nonessential files that don't have duplicates. The remaining duplicated files are highlighted for either deletion or for moving to external drives.

Any ideas on how to accomplish this? Thanks.

See the attached.