Deleting Duplicate Files
Author
Discussion

paulrockliffe

Original Poster:

16,615 posts

257 months

Monday 29th March 2021
quotequote all
I have a load of MP3s that have been bastardised by various organisation programs over the years. I can't remember what the last one I used on them was but it made a proper mess of them! This was a few years ago, but I finally decided to try to sort them out because I've sorted out a major blocker - I've managed to setup something that will identify albums with missing tracks, so once they're all sorted I can't start filling the gaps back in.

Anyway, I've got a process running now using MusicBrainz Picard to put everything into the right Artist/Artist - Album folders and rename all the tracks to the right format. I'll then import the results into Lidarr and go hunting for missing tracks.

But I've been spot-checking albums and identified an issue with duplication - I don't know why but I naively assumed that MusicBrainz would not create duplicate tracks within an Album, because it's really easy to end up with duplicates and no one wants that. But it doesn't, so I have "01 TRACK" and "01 TRACK (01)" and "01 TRACK (2)" etc, which is more than a little irritating.

Does anyone know an easy way to delete these? Ideally a method that compares the files in the folder rather than relying on the file name, though perhaps I need to do both as I expect there are some different file formats of the same track.

Thanks

bristoltype603

256 posts

77 months

Monday 29th March 2021
quotequote all
Probably not a lot of help but the way I solved this problem a while ago was using a (free) program called jdupes. Brilliant but as far I can tell only runs on linux. Maybe there's something similar for windows?

xeny

5,511 posts

108 months

Monday 29th March 2021
quotequote all
Doublekiller. Free, and will compare based on one or more of file contents, size, date, you name it, and then either delete things it thinks are duplicates, or optionally move them to another folder for you to check.

https://www.bigbangenterprises.de/en/doublekiller/

paulrockliffe

Original Poster:

16,615 posts

257 months

Monday 29th March 2021
quotequote all
bristoltype603 said:
Probably not a lot of help but the way I solved this problem a while ago was using a (free) program called jdupes. Brilliant but as far I can tell only runs on linux. Maybe there's something similar for windows?
Thanks, the files are on a linux-based server and you can run Linux in Windows too now, so I can probably make that work. Will look at that other option too.

Crafty_

14,177 posts

230 months

Monday 29th March 2021
quotequote all
You could just look for any files that match *(*)* - review the list in case you've got some "The song - the artist (featuring someone else)".

To avoid that you could use a regex to look for anything with (<a number>), sonething like find . -regex .*\([0-9]\).* from memory.

stick the resulting list in to a file and then just alter the file to delete them and execute.

norton-your-nelly

220 posts

265 months

Tuesday 30th March 2021
quotequote all
I use https://www.digitalvolcano.co.uk/duplicatecleaner....

It has an audio track mode, where you can compare tags as well as file content.

There is a free version you can see if it does what you want. I was sceptical at first, but it is one of the few free trials that I've actually gone on to buy!

sgrimshaw

7,587 posts

280 months

Tuesday 30th March 2021
quotequote all
There are utilities available which find duplicates even when the file names are not the same.

One example is File Fusion from Abelssoft:

https://www.abelssoft.de/en/windows/system-utiliti...

I've used that just to find duplicates, but I don't let it do it's optimisation. As it's trying to be easy to use, it does lack control when it searches etc

Another which I've yet to try, although I should as it's free, is this one:

http://www.find-duplicates.com/Duplicate_File_Find...

This one has various guises too, one is specifically for mp3 files:

http://www.find-duplicates.com/Duplicate_MP3_Finde...

paulrockliffe

Original Poster:

16,615 posts

257 months

Tuesday 30th March 2021
quotequote all
Thanks, I'm currently trying Duplicate Killer first.

It's done a decent job, but it's hit an issue with different bit-rates on the first run. Different file-size = No duplicate. I'm running it through again matching only on checksum, but I'm not sure if this as a good idea, whether the checksums will be different anyway or whether I'd be better using something else for this step.

paulrockliffe

Original Poster:

16,615 posts

257 months

Tuesday 30th March 2021
quotequote all
Proper slow just comparing checksums, I guess that takes a bit more effort than looking at file sizes. Oh well, I'm in no rush!

paulrockliffe

Original Poster:

16,615 posts

257 months

Tuesday 30th March 2021
quotequote all
Crafty_ said:
You could just look for any files that match *(*)* - review the list in case you've got some "The song - the artist (featuring someone else)".

To avoid that you could use a regex to look for anything with (<a number>), sonething like find . -regex .*\([0-9]\).* from memory.

stick the resulting list in to a file and then just alter the file to delete them and execute.
It looks like this might be my best shot, I tried a few options but not really getting anywhere. I understand how this is working, but what program should use to perform the search and delete?

xeny

5,511 posts

108 months

Tuesday 30th March 2021
quotequote all
paulrockliffe said:
Proper slow just comparing checksums, I guess that takes a bit more effort than looking at file sizes. Oh well, I'm in no rush!
If the sizes are different, the checksums will definitely differ.

paulrockliffe

Original Poster:

16,615 posts

257 months

Tuesday 30th March 2021
quotequote all
xeny said:
paulrockliffe said:
Proper slow just comparing checksums, I guess that takes a bit more effort than looking at file sizes. Oh well, I'm in no rush!
If the sizes are different, the checksums will definitely differ.
Yeah, that's what I thought, so I cancelled it out and tried it on a subfolder with duplicates to check. Didn't find any.

Crafty_

14,177 posts

230 months

Tuesday 30th March 2021
quotequote all
paulrockliffe said:
Crafty_ said:
You could just look for any files that match *(*)* - review the list in case you've got some "The song - the artist (featuring someone else)".

To avoid that you could use a regex to look for anything with (<a number>), sonething like find . -regex .*\([0-9]\).* from memory.

stick the resulting list in to a file and then just alter the file to delete them and execute.
It looks like this might be my best shot, I tried a few options but not really getting anywhere. I understand how this is working, but what program should use to perform the search and delete?
just at the command prompt, so if you did the find . -regex .*\([0-9]\).* > list_of_duplicate_files

then use vi to edit the file, if there are a lot you could probably use another regex to look for "anything followed by a full stop" and replace it with "rm whatever the file name was.", rename the file with a .sh extension and then ./list_file_files.sh

something along those lines anyway, not a total linux geek but you don't need any software.

.. if you are doing it on windows I'd download notepad++, get a file listing use a regex to find the duplicates using a regex like above, then use a macro to insert "del " at the start of each line.

xeny

5,511 posts

108 months

Tuesday 30th March 2021
quotequote all
paulrockliffe said:
Yeah, that's what I thought, so I cancelled it out and tried it on a subfolder with duplicates to check. Didn't find any.
That's very odd - I get the impression you're using it on a network file system - does it find duplicates for you on a local file system?

It doesn't like files over 2GB, but that shouldn't be a problem for MP3s.

paulrockliffe

Original Poster:

16,615 posts

257 months

Wednesday 31st March 2021
quotequote all
xeny said:
paulrockliffe said:
Yeah, that's what I thought, so I cancelled it out and tried it on a subfolder with duplicates to check. Didn't find any.
That's very odd - I get the impression you're using it on a network file system - does it find duplicates for you on a local file system?

It doesn't like files over 2GB, but that shouldn't be a problem for MP3s.
The problem is the files aren't duplicates, they have the same name but they're different bit-rates so different sizes and different check sums. Then when Music Brainz puts them in the correct folders and renames them the files then end up with different names too!

I think what I want to do is more basic - find and delete any file with a name that ends in "(number)". I'm not too bothered if that's a bit crude as the next step will be to run it all through Lidarr and fill in any gaps. I already have gaps so it doesn't matter if there's more to fill.

xeny

5,511 posts

108 months

Wednesday 31st March 2021
quotequote all
What happens if you simply use find in Windows Explorer to search for ) do a quick eyeball they're all expendable, select all and delete?

Rampant Golf

2,808 posts

240 months

Wednesday 31st March 2021
quotequote all
Treesize search on the md5 checksum. It'll deal with 80% of the duplication and the rest will be a manual effort due to varying sizes and qualities of the files. Remember some duplication is good - compilations etc.


paulrockliffe

Original Poster:

16,615 posts

257 months

Wednesday 31st March 2021
quotequote all
xeny said:
What happens if you simply use find in Windows Explorer to search for ) do a quick eyeball they're all expendable, select all and delete?
I tried searching in windows and for some reason searching for *(*)* returned all the files! I decided that I didn't understand search well enough and that's what prompted me to ask how I search and delete earlier in the thread!

That would be the easiest approach. I think I know how to do it in Power Shell or Linux command prompt thingy, but I'll need some time to google exactly what I need to type in, so I've not tried that yet.

paulrockliffe

Original Poster:

16,615 posts

257 months

Wednesday 31st March 2021
quotequote all
Rampant Golf said:
Treesize search on the md5 checksum. It'll deal with 80% of the duplication and the rest will be a manual effort due to varying sizes and qualities of the files. Remember some duplication is good - compilations etc.
I don't have any compilations as I only listen to proper albums and one of my previous attempts to sort it out would have split any compilations into their component albums anyway, I'm sure.

I don't really care about retaining the best sound quality as over time Lidarr will pick up any poor quality versions and replace them, so it doens't matter too much which file ends up being retained.

paulrockliffe

Original Poster:

16,615 posts

257 months

Wednesday 31st March 2021
quotequote all
Looks like this:

~"*(*)" name:

Is the Windows Search I was looking for.

Seems to be working OK, though it would be better if there was a number wildcard available as it's going to kill some song names that have something in brackets in the name such as Don't Ever Think (Too Much) by the Zutons. But I'll probably just murder those and rebuild rather than messing around any more.