David A. Harding on 2 Jun 2009 21:22:43 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Versatile Flac Tag Editor Wanted


On Tue, Jun 02, 2009 at 07:59:13PM -0400, Casey Bralla wrote:
> Anybody know of a tag editor that is truly versatile and will accept any 
> custom field?

I use metaflac, a command-line program, to dump the FLAC metadata to a
temporary text file, edit the file with $EDITOR, and overwrite the FLAC
metadata with the contents of the temporary text file.

I'm pasting the script I use below my signature. Even if you don't use
it, you may find parts of the code useful for inserting your database
into FLAC metadata with metaflac automatically.

Good luck,

-Dave

#!/bin/bash -eu

## editflac by David A. Harding <dave@dtrt.org>
#
## No restrictions on use, modification, redistribution, or study. This
## software comes with no warranty, not even the implied warranty of
# merchantability or fitness for a particular purpose.

FLAC_FILE="$1"
TMP_FILE=$(mktemp) || {
    echo "Cannot create temporary file.  Dying..."
    exit 1
}

## Populate temporary file
{
    echo "# FLAC metadata for $FLAC_FILE"
    echo "# From hash (#) to end of line ignored; empty lines ignored."

    metaflac --export-tags-to=- "$FLAC_FILE"

    cat << __END_OF_COMMENTS__

## Common tags -- remember to uncomment if you use them.
## Don't surround data with quotes; don't wrap lines.
#ARTIST=
#ALBUM=
#TITLE=
## Date field is ISO: YYYY-MM-DD
#DATE=
#GENRE=
#TRACKNUMBER=

## Less common tags.  Same rules apply.
#LOCATION=
## Only for classical music and covers
#PERFORMER=

## Custom tags: you can enter anything as long as it follows the
## above rules.  For example:
#X-HARDINGS_FAVORITES=1
__END_OF_COMMENTS__

} > "$TMP_FILE"

${EDITOR:-vi} "$TMP_FILE"

sed 's/#.*//; /^$/d' "$TMP_FILE" \
    | metaflac --remove-all-tags --import-tags-from=- "$FLAC_FILE" ||
    {
	echo "Import Failed!"
	echo "You can find your changes in $TMP_FILE"
	exit 1
    }

rm -f -- "$TMP_FILE"
-- 
David A. Harding	    Website:  http://dtrt.org/
1 (609) 997-0765	      Email:  dave@dtrt.org
			Jabber/XMPP:  dharding@jabber.org
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug