[Flac] metaflac-edit utility and suggestion for metaflac --export-tags option

Dat Head dathead2 at gmail.com
Sat Mar 28 16:54:45 PDT 2009


here is a simple utility I wrote for myself and thought maybe others
on linux/cygwin/unix could find it of use
called metaflac-edit (can change, delete or add new metaflac tags)

also I would like to suggest that --export-tags-to=- be given a
synonym of --show-all-tags


#!/bin/sh
#
#	metaflac-edit - META info FLAC EDITor
#
# NOTE: use metaflac-set to just quickly change or add one meta tag

TMPDIR=${TMPDIR:-/var/tmp}
TMPFILE=$TMPDIR/$$.$RANDOM
EDITOR="${EDITOR:-vi}"
self=$(basename $0)

files=${*:-*.flac}

for file in $files
do

  if [ ! -f $file ]; then
    echo "$self: $file: no such file" >&2
    continue
  fi

  echo "=============== $file before $self ==============="
  metaflac --export-tags-to=- $file

  metaflac --export-tags-to=$TMPFILE $file
  $EDITOR $TMPFILE

  exec 3<$TMPFILE
  read -u3 line
  status=$?
  while [ $status -eq 0 ]
  do
    tag="$(echo $line | cut -d= -f1)"
    val="$(echo $line | cut -d= -f2)"
    metaflac --remove-tag="$tag" $file
    metaflac --set-tag="$tag"="$val" $file
    read -u3 line
    status=$?
  done

  echo
  echo "=============== $file after $self ==============="
  metaflac --export-tags-to=- $file

done

/bin/rm -f $TMPFILE


More information about the Flac mailing list