Science and technology

How to handle music tags utilizing metaflac

I have been ripping CDs to my laptop for a very long time now. Over that point, I’ve used a number of totally different instruments for ripping, and I’ve noticed that every instrument appears to have a distinct tackle tagging, particularly, what metadata to avoid wasting with the music knowledge. By “observed,” I imply that music gamers appear to kind albums in a humorous order, they break up tracks in a single bodily listing into two albums, or they create different kinds of irritating irritations.

I’ve additionally realized that a number of the tags are fairly obscure, and lots of music gamers and tag editors do not present them. Even so, they could use them for sorting or displaying music in some edge instances, like the place the participant separates all of the music information containing tag XYZ into a distinct album from all of the information not containing that tag.

So if the tagging functions and music gamers do not present the “weirdo” tags—however are by some means affected by them—what are you able to do?

I’ve been which means to get acquainted with metaflac, the open supply command-line metadata editor for FLAC files, which is my open supply music file format of alternative. Not that there’s something flawed with nice tag-editing software program like EasyTAG, however the previous saying “if all you have is a hammer…” involves thoughts. Also, from a sensible perspective, my residence and workplace stereo music wants are met by small, devoted servers working Armbian and MPD, with the music information saved regionally, working a really stripped-down, music-only headless atmosphere, so a command-line metadata administration instrument can be fairly helpful.

The screenshot beneath exhibits the everyday downside created by my long-term ripping program: Putumayo’s fantastic compilation of Colombian music seems as two separate albums, one containing a single observe, the opposite containing the remaining 11:

I used metaflac to generate an inventory of all of the tags for the entire FLAC information within the listing containing these tracks:

rm -f tags.txt
for f in *.flac; do
        echo $f >> tags.txt
        metaflac --export-tags-to=tags.tmp "$f"
        cat tags.tmp >> tags.txt
        rm tags.tmp
executed

I saved this as an executable shell script (see my colleague David Both‘s fantastic collection of columns on Bash shell scripting, particularly the one on loops). Basically, what I am doing right here is making a file, tags.txt, containing the filename (the echo command) adopted by all its flags, adopted by the following filename, and so forth. Here are the primary few traces of the consequence:

A Guapi.flac
TITLE=A Guapi
ARTIST=Grupo Bahia
ALBUMARTIST=Various Artists
ALBUM=Putumayo Presents: Colombia
DATE=2001
TRACKTOTAL=12
GENRE=Latin Salsa
MUSICBRAINZ_ALBUMARTISTID=89ad4ac3-39f7-470e-963a-56509c546377
MUSICBRAINZ_ALBUMID=6e096386-1655-4781-967d-f4e32defb0a3
MUSICBRAINZ_ARTISTID=2993268d-feb6-4759-b497-a3ef76936671
DISCID=900a920c
ARTISTSORT=Grupo Bahia
MUSICBRAINZ_DISCID=RwEPU0UpVVR9iMP_nJexZjc_JCc-
COMPILATION=1
MUSICBRAINZ_TRACKID=8a067685-8707-48ff-9040-6a4df4d5b0ff
ALBUMARTISTSORT=50 de Joselito, Los
Cumbia Del Caribe.flac

After a little bit of investigation, it seems I ripped plenty of my Putumayo CDs on the identical time, and no matter software program I used to be utilizing on the time appears to have put the MUSICBRAINZ_ tags on all however one of many information. (A bug? Probably; I see this on a half-dozen albums.) Also, with respect to the typically uncommon sorting, observe the ALBUMARTISTSORT tag moved the Spanish article “Los” to the tip of the artist identify, after a comma.

I used a easy awk script to record all of the tags reported within the tags.txt file:

awk -F= 'index($zero,"=") > zero ' tags.txt | kind -u

This break up all traces into fields utilizing = as the sphere separator and prints the primary subject of traces containing an equals signal. The outcomes are handed by way of kind with the -u flag, which eliminates all duplication within the output (see my colleague Seth Kenlon’s nice article on the sort utility). For this particular tags.txt file, the output is:

ALBUM
ALBUMARTIST
ALBUMARTISTSORT
ARTIST
ARTISTSORT
COMPILATION
DATE
DISCID
GENRE
MUSICBRAINZ_ALBUMARTISTID
MUSICBRAINZ_ALBUMID
MUSICBRAINZ_ARTISTID
MUSICBRAINZ_DISCID
MUSICBRAINZ_TRACKID
TITLE
TRACKTOTAL

Sleuthing round a bit, I discovered that the MUSICBRAINZ_ flags seem on all however one FLAC file, so I used the metaflac command to delete these flags:

for f in *.flac; do metaflac --remove-tag MUSICBRAINZ_ALBUMARTISTID "$f"; executed
for f in *.flac; do metaflac --remove-tag MUSICBRAINZ_ALBUMID "$f"; executed
for f in *.flac; do metaflac --remove-tag MUSICBRAINZ_ARTISTID "$f"; executed
for f in *.flac; do metaflac --remove-tag MUSICBRAINZ_DISCID "$f"; executed
for f in *.flac; do metaflac --remove-tag MUSICBRAINZ_TRACKID "$f"; executed

Once that is executed, I can rebuild the MPD database with my music participant. Here are the outcomes:

And, there we’re—all 12 tracks collectively in a single album.

So, yeah, I am lovin’ metaflac an entire bunch. I count on I will be utilizing it extra typically as I attempt to wrangle the final bits of weirdness in my music assortment’s music tags. It’s extremely advisable!

And the music

I have been spending a couple of evenings listening to Odario Williams’ program After Dark on CBC Music. (CBC is Canada’s public broadcasting company.) Thanks to Odario, one of many albums I’ve actually come to get pleasure from is Songs for Cello and Voice by Kevin Fox. Here he’s, masking the Eurythmics tune “Sweet Dreams (Are Made of This).”

I purchased this on CD, and now it is on my music server with its tags correctly organized!

Most Popular

To Top