--- vorbistagedit.orig 2009-08-01 12:14:03.810799999 +0200 +++ vorbistagedit.flac 2009-08-12 00:23:22.865477438 +0200 @@ -1,12 +1,12 @@ #!/bin/sh -eu -# vorbistagedit -- allows batch editing of vorbis comments with an editor +# vorbistagedit -- allows batch editing of vorbis and flac comments with an editor # # Copyright © martin f. krafft # Released under the terms of the Artistic Licence 2.0 # -VERSION=0.5 +VERSION=0.6 ME=${0##*/} versioninfo() { @@ -19,7 +19,7 @@ usage() { versioninfo echo - echo Usage: $ME file1.ogg [file2.ogg [file3.ogg ...]] >&2 + echo Usage: $ME file1.ogg [file2.flac [file3.ogg ...]] >&2 echo echo If no filenames are given, the list of filenames >&2 echo is read from stdin, one per line. >&2 @@ -41,11 +41,6 @@ esac done -if ! command -v vorbiscomment >/dev/null; then - echo "E: $ME: vorbiscomment not found in \$PATH." >&2 - exit -1 -fi - old_IFS="$IFS" IFS=" " @@ -74,6 +69,11 @@ for i in "$@"; do case "$i" in *.ogg) + if ! command -v vorbiscomment >/dev/null; then + echo "E: $ME: vorbiscomment not found in \$PATH." >&2 + exit -1 + fi + if [ ! -r "$i" ]; then echo "E: $ME: unreadable file: $i" >&2 exit 2 @@ -90,6 +90,28 @@ echo ;; + *.flac) + if ! command -v metaflac >/dev/null; then + echo "E: $ME: metaflac not found in \$PATH." >&2 + exit -1 + fi + + if [ ! -r "$i" ]; then + echo "E: $ME: unreadable file: $i" >&2 + exit 2 + fi + + if [ ! -w "$i" ]; then + echo "E: $ME: unwriteable file: $i" >&2 + exit 3 + fi + + echo ": $i" + echo "+ $i" + metaflac --export-tags-to - "$i" + echo + ;; + *) echo "E: $ME: invalid argument: $i" >&2 exit 1 @@ -126,8 +148,10 @@ write_tags() { echo -n "I: processing $file... " >&2 + local ext=$(echo $file | tail -c5) local file="$1"; shift - for tag; do echo "$tag"; done | vorbiscomment -w "$file" + [ "$ext" = '.ogg' ] && for tag; do echo "$tag"; done | vorbiscomment -w "$file" + [ "$ext" = 'flac' ] && for tag; do echo "$tag"; done | metaflac --remove-all-tags --import-tags-from - "$file" if [ -n "${filename_new:-}" ] && [ "${filename_new:-}" != "$file" ]; then echo; echo -n "I: renaming to $filename_new... " >&2 mv "$file" "$filename_new"