Skip to content

Duplicates

Outcome: you can find the tracks your library holds twice, understand the three different things "duplicate" can mean, and delete the spares without deleting the wrong one. All of it is transcript t07-duplicates.txt, including the two ways the search fails first — which are the chapter's real lessons.

Setting up the problem

The lab imported a byte-for-byte copy of a track it already owned, under a different filename in a different folder. As-is import filed it as its own little album record (the importer's keep answer, set in advance — chapter 7), and beet ls then showed the title twice. Six tracks became seven; one song is in the library two times. Now: find it with the tool whose whole job is that, the duplicates plugin (switched on in the config — chapter 9).

First failure: the default keys are MusicBrainz IDs

beet duplicates
(no output)

By default the plugin groups tracks by their MusicBrainz identifiers — mb_trackid with mb_albumid. That is the right default for an autotagged library, where those IDs are the ground truth of "same recording". The lab's as-is tracks have no such IDs, so the groupings come up empty and the command finds nothing to say. Silence, here, does not mean no duplicates; it means no duplicates by the definition you asked for. Most "the tool found nothing" stories in most tools are this story.

The tag-key definition

Name the fields to group by, with -k, and the duplicate appears:

beet duplicates -k albumartist -k album -k title
The Lab Tones - First Experiments - Sine Wave Sunrise

That prints the spare — --full prints every copy, original included. Tag keys answer the question "same song, by name?" — which is usually the question a person cleaning a library is asking, and it works whether or not anything was ever matched against MusicBrainz.

Second failure: the checksum that beets itself defeated

The third definition is by content: -C gives the plugin a checksum program to run per file, ffmpeg's audio CRC being the classic choice:

beet duplicates -C 'ffmpeg -i {file} -f crc -' --full
(no output)

The copies are byte-identical at birth — the transcript proves the fixtures matched — so why nothing? Because one of them had been through a beets import and the other had too, but only one album had a cover picture: the import embedded that picture into its tracks' files (chapter 9), changing the bytes and even the audio CRC (the picture is a stream in the file, and the CRC is taken over the file's streams). ffprobe output in the transcript shows the difference plainly: one file has an mjpeg stream, the other only mp3. The lesson is worth the paragraph: file-level duplicate detection is fragile exactly where a tag manager has been at work. Beets' own housekeeping — rewritten tags, embedded art — legitimately changes files, so "same bytes" stops meaning "same track" the moment the library is loved. Group by tags for identity; reserve checksums for hunting exact file copies in an untouched archive.

Deleting the spare

With the definition settled, the deletion is one flag on the same command:

beet duplicates -k albumartist -k album -k title --delete

It lists what it will remove — the spare only, never every copy — and removes it from the database and the disk together. beet stats afterwards is the chapter's check: the lab's library returned to six tracks and two albums. Two cautions belong with the power. --delete trusts the grouping completely, so run the bare listing first and read it as a reviewer, not a formality — a live take and a studio take with identical title tags group together under tag keys. And keep the query habit from chapter 5: a duplicates report scoped by a query argument only hunts within that scope, which is how you clean one artist at a time instead of the whole shelf at once.