Getting rid of unwanted tags in FLAC files (Linux only, of course)

For those that still deal with local digital files here’s a quick way to get rid of unwanted tags added by the likes of musicbrainz taggers, labels etc. Unfortunately metaflac doesn’t provide a nice clean --delete-all-tags-except option, so I devised this method as a crude workaround because no matter how much I try I inevitably let some crud slip through. This script takes care of that for once and for all. Modify to suit your needs (and use at your own risk)…


for arg
# list the tags you'd like to preserve here
metaflac \
--show-tag discnumber \
--show-tag tracknumber \
--show-tag title \
--show-tag composer \
--show-tag artist \
--show-tag personnel \
--show-tag albumartist \
--show-tag album \
--show-tag version \
--show-tag discsubtitle \
--show-tag live \
--show-tag work \
--show-tag part \
--show-tag originalreleasedate \
--show-tag year \
--show-tag genre \
--show-tag style \
--show-tag recordinglocation \
--show-tag recordingstartdate \
--show-tag performancedate \
--show-tag roonalbumtag \
--show-tag roontracktag \
--show-tag compilation \
--show-tag acoustid_id \
--show-tag acousticbrainz_mood \
--show-tag musicbrainz_albumartistid \
--show-tag musicbrainz_albumid \
--show-tag musicbrainz_artistid \
--show-tag musicbrainz_discid \
--show-tag musicbrainz_trackid \
--show-tag discogs_artist_url \
--show-tag discogs_release_url \
"$arg" | metaflac --preserve-modtime --remove-all-tags --import-tags-from=- "$arg"

invoke it in the parent folder of the tree you want to process:
find . -type f -name '*.flac' -exec ~/ {} +

One thing to note, due to what appears to be a bug in metaflac, metaflac will not process any tags containing CR or LF, so you’re out of luck if you have a lyrics tag.