Ubuntu – How to find and delete duplicate music tracks

11.10bansheeduplicate filesmusic

My issue is that for some reason I have duplicates of some music tracks. However they are not named identically. For instance:

Music/Prefuse 73/One Word Extinguisher/07. Detchibe.mp3

&

Music/Prefuse 73/One Word Extinguisher/07 – Detchibe.mp3

Notice they are duplicate songs but the 07*.* & the 07 is tricking duplicate file finders that search based on file names.

Best Answer

You can use fdupes like the answer for question »How to find and delete duplicate files« suggested. Let me give an example:

mkdir -p "Music/Prefuse 73/One Word Extinguisher/"
dd if=/dev/urandom of=Music/Prefuse\ 73/One\ Word\ Extinguisher/07.Detchibe.mp3 bs=1023 count=2048
  2048+0 records in
  2048+0 records out
  2095104 bytes (2.1 MB) copied, 0.379806 s, 5.5 MB/s
cp Music/Prefuse\ 73/One\ Word\ Extinguisher/07.Detchibe.mp3 Music/Prefuse\ 73/One\ Word\ Extinguisher/"07 - Detchibe.mp3"
fdupes -rd .
  [1] ./Music/Prefuse 73/One Word Extinguisher/07.Detchibe.mp3
  [2] ./Music/Prefuse 73/One Word Extinguisher/07 - Detchibe.mp3

  Set 1 of 1, preserve files [1 - 2, all]:

First I created the directory like in your example. The I made a file from random data and copied its contents to another files. When I run fdupes -rd the software finds the two exact files and asks which one to delete.

If you have lots of files, you can use the option -1. fdupes will print all duplicates on a single line. You can process them with xargs and other shell features.