VBA or Script to identify files which are duplicate in a folder

Flora Edwards
Flora Edwards used Ask the Experts™
i have a very tricky situation with my files.

i have a folder which has duplicates like this, how can i delete one copy of them and delete the other so that there is unique left?

is there any way to do this automatically without manual process?


Creating A Search Box.xlsm

Contacts List Template.xlsm
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Rob HensonFinance Analyst

I don't have any suggestions as that is not my field but no doubt the question will be asked; how will you determine which file to keep and which to delete?

Rob H

VBA could do the trick,

enumerate all files in two loops, compare MD5 hash of the two files. Delete if the same.
To reduce system load, only compare if first x letters of the file name (maybe 3 or 5?) are the same.
However, you will NOT have a choice for the file name (if the shorter file name is prettier, but it's the one in the first loop, you obviously can't delete it).
Top Expert 2016

I would use a utility like beyond compare
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Or you can use this simple ExcelDupeCleaner I threw together for you.
Flora EdwardsMedicine


thanks everyone.

MacroShadow Solution was absolutely perfect.  thanks very much. this is extraordinary
You're welcome, glad to help!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial