Avatar of Flora Edwards
Flora Edwards
Flag for Sweden asked on

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

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?

Anonymizing-Data.xlsm
Anonymizing-Data-wngz.xlsm

Creating-A-Search-Box-40t1.xlsm
Creating A Search Box.xlsm

Contacts List Template.xlsm
Contacts-List-Template.xlsm
VBAMicrosoft ExcelVB ScriptMicrosoft Office

Avatar of undefined
Last Comment
Joe Howard

8/22/2022 - Mon
Rob Henson

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?

Thanks
Rob H
Kimputer

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).
David Johnson, CD

I would use a utility like beyond compare
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER CERTIFIED SOLUTION
Joe Howard

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Flora Edwards

ASKER
thanks everyone.

MacroShadow Solution was absolutely perfect.  thanks very much. this is extraordinary
Joe Howard

You're welcome, glad to help!