Skip to content

How to Tidy Up Your Music Collection with BASH and metaflac

20/06/2009

I recently ripped my 450 or so CDs to FLAC using Audio CD Extractor (Sound Juicer) for my SqueezeCenter. This does a really good job since it will automatically retrieve track information from MusicBrainz. The final step is to add album art to the files (there’s already a cover.jpg file in each album folder.)

After trying just about every tagger suitable for Ubuntu (and compiling Pinky-Tagger.) I quickly realised that this would be a long and tedious task… unless I could do something using the BASH command line. This is what I did.

First, remove all existing artwork:

$ find . -name "*.flac" -type f -execdir metaflac --remove --block-type=PICTURE {} \;

Unfortunately, it’s not possible to mix major operations so you’ll only see errors output from this instruction. If you want to test first replace –remove –block-type=PICTURE with –show-tag=TITLE. For example:

./Giacomo Puccini/La Bohème (Berliner Philharmoniker feat. conductor: Herbert von Karajan, soprano: Mirella Freni, tenor: Luciano Pavarotti)/Giacomo Puccini-La Bohème (Berliner Philharmoniker feat. conductor: Herbert von Karajan, soprano: Mirella Freni, tenor: Luciano Pavarotti)-04-La Bohème: Act I. "Si può_" (Benoit).flac: ERROR: reading metadata, status = "FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE"
The FLAC file could not be opened.  Most likely the file does not exist
or is not readable.

I had three such errors in over 6,000 tracks.

Finally, add the cover art:

find . -name "*.flac" -type f -execdir metaflac --import-picture-from="cover.jpg" --show-tag="Title" {} \;

If you try this, test on one or two folders first (it’s recursive) and back up your important files!

One Comment
  1. Rob Collins permalink

    Hey thanks man for this extremely helpful tip which worked very well. Gosh I love the power of linux command line. It is just a shame that my favourite player amarok STILL does not read embedded cover art while just about every other app you can think of does.

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 457 other followers