Delete Duplicates Within Folders, Keep Them Across Multiple Folders

Hi there! I am in a Directory Opus Pro trial and still getting the hang of things. Most stuff seems straightforward and I am really enjoying it so far. Anyway... here is what I would like to do. I found some partially related posts, but from over 10 years ago so I didn't want to cobble together bits from old conversations.

I would like to find duplicate files and delete duplicates (based on MD5) that are within the same folder, but not from across multiple folders. I will give an example to explain/clarify.

Running Duplicate File Finder (based on MD5) on C:\Test

In C:\Test exists folders TestA and TestB

File2 (it would have a different filename, of course, but based on MD5 is the same as File2)


Those instants of duplication, the files have different names but are the same based on MD5.

Up to this part... no issues, DO is clear and works great.

Now what I want to do, if possible, is automatically (or easily without going 1 by 1 manually) delete all but one copy of a file on a per directory basis.

So in my example case, one instance of File2 would be deleted from TestA, but it would NOT be deleted from TestB. And one instance of File1 would be deleted from TestB, but it would NOT be deleted from TestA.

I hope that is clear, thanks in advance for the help.

Needs a script that loops through the folders and feeds them to the Find command. I have something I can tidy up and publish.


That would be amazing, thank you!

Have a look :slight_smile:


It works perfectly at finding and selecting the files!! Thank you very much.

I cannot, though, seem to delete them? Haha. Not sure if that is script related at all, might just be brain related for me.

I tried both with and without the recycle bin target and nothing happens. I hit delete (the button in the Dupe Finder, not the main toolbar) and nothing. If I choose the Delete option for with or without recycle, also nothing.

Are you sure you picked the right collection?

:four: After the command has finished make sure the correct collection is selected in the panel, otherwise you may be unable to select and delete files.

Just seeing it in the file display is not enough :slight_smile:

I am probably confused, haha. Ok, so immediately after running your amazing script (thanks again!), and not doing anything else, this is where I am at:

I sort of assumed I should then check "Delete Mode", hit Find, then proceed to use the Delete button. But that must be wrong, lol.

1 Like

as for me also. 'delete' button inactive


Did you pick the right collection? It's probably showing the results from a previous run.

yes, i can select a right coll: only after running a script. right? (before it a coll: doesn't exist) but nothing changes...

I see!!! Ok, so I then change the selection in that box to the name of the collection at the top. Then, while the Delete button is still inactive, I can hit Select and then I can simply delete with the delete key on the keyboard or right click and delete. That seemed to work!


After selecting files the Delete button should become active. If it doesn't but you can still delete via keyboard, well... :slight_smile: The Find panel is indeed a bit mysterious :crazy_face:

Actually, I think I found an issue. If the last folder has no duplicates, the script fails to mark the duplicates.

I did my test basically the same as how I laid it out in my first post... except with 3 folders: Test1, Test2, and Test3.

If there are dupes in 1 and 2, but not 3, nothing is marked. Any combination of 1 and 2 but not 3 is the same.

If 1 and 2 and 3 all have dupes, good. If only 3 has dupes, good. If 3 is empty, no good.

If I add a 4th folder, then it works again contingent upon 4 having dupes rather than 3.

I suppose this is not the end of the world, I just know I need to add a folder to the end of those checked that has dupes, lol.

That's interesting! However, fixing this is beyond the script. It just hands over the folders to the Duplicate File Finder which will process them.

1 Like

Understood and really not a massive issue. I am currently about to run this thing on a massive number of folders (around 2000), lol. I just added one to the end named "Zzzzz" and put some dupe text files in it. It's currently working it's way through the folders, I'll report back how it goes!

It worked perfectly... thanks for the huge time saving. If you have PayPal or Venmo or something where you'd be comfortable with me buying you a coffee or beer, let me know.