Fixing a 6,200-track library where every album had the wrong year

这篇内容暂时只有 English 版本,以下是原文。

Last spring I inherited a 6,200-track library from a friend who had ripped it over fifteen years across three laptops. Most of it was FLAC, some 320 kbps MP3, and the metadata was a mess in one specific way: album years were wrong almost everywhere. Not missing — wrong. A 1974 record showed 2003, reissues and originals were mixed, and compilations had the year of the compilation rather than the recordings. Genre tags were fine, artist tags were mostly fine, so the problem stayed hidden until I started sorting by decade.

I didn’t want to retag by hand. I also didn’t trust a single online database, because the whole library had clearly been touched by one at some point. What I did instead was make the files prove their own dates.

First, a read-only pass that dumped what I actually had, without writing anything back:

find /music -type f \( -iname '*.flac' -o -iname '*.mp3' \) -print0 \
  | xargs -0 -n1 -P4 sh -c '
    f="$1"
    if [ "${f##*.}" = flac ]; then
      echo "$f	$(metaflac --show-tag=DATE "$f" | cut -f2)"
    else
      echo "$f	$(ffprobe -v quiet -show_entries format_tags=date -of default=nw=1:nk=1 "$f")"
    fi' _ > /tmp/years_before.tsv

Then I pulled two independent signals per album: the earliest release year from the file’s own tags across all tracks on that album, and the median year of the other albums by the same artist already in the library. Where those disagreed by more than two years, I flagged it rather than fixing it. About 900 albums got flagged; the rest I left alone, because a wrong year is less harmful than a confident wrong year written over a right one.

The mechanism matters here: album year is not a property of the audio, it’s a property of the release you happen to hold. A 1974 recording reissued in 2003 legitimately has 2003 on the sleeve. So my rule was to keep the reissue year when the folder name or the catalog number suggested a reissue, and to prefer the original otherwise. I encoded that as a small table, album_dir -> intended_year, and applied it with a dry run first:

while IFS=$'\t' read -r f y; do
  echo "would set $f -> $y"
done < /tmp/years_fix.tsv | head -50

Only after reading those fifty lines did I run the write pass. The cost is real: I spent about six hours on this, and roughly 300 albums still need a human decision because the two signals disagree and neither is obviously right. If your library is smaller than a few thousand tracks, this is not worth it — sort by folder and move on. It also fails badly for compilations and for artists with few albums, where the median-year signal has nothing to stand on. I got burned once by a live bootleg folder that had the concert date in the year field; the script happily “corrected” it to the studio album year before I noticed. Now bootlegs and anything with “live” in the path are excluded by default.

What I still can’t decide: when the original and the reissue are both defensible, do you keep the year you’d tell someone the record is from, or the year on the copy you own?

0
赞同度 100% · 0 条评论 · 4 阅读

0 条评论

支持 Markdown · 回复会实时推送给对方

还没有评论,写下第一条。