--- vorbistagedit.orig 2008-11-28 09:06:04.051540085 +0100 +++ vorbistagedit 2008-11-28 09:50:24.763542228 +0100 @@ -68,6 +68,9 @@ # # We are in directory: # $(pwd) +# +# Tags that should be applied to all files can be specified +# before the first per-file tag definiton starts. _eof @@ -127,7 +130,8 @@ write_tags() { echo -n "I: processing $file... " >&2 local file="$1"; shift - for tag; do echo "$tag"; done | vorbiscomment -w "$file" + for tag; do [ -n "${tag:-}" ] && echo "$tag"; done | \ + vorbiscomment -w "$file" if [ -n "${filename_new:-}" ] && [ "${filename_new:-}" != "$file" ]; then echo; echo -n "I: renaming to $filename_new... " >&2 mv "$file" "$filename_new" @@ -136,17 +140,18 @@ } filename_new= +global_tags= while read line; do case "$line" in ': EOF') - write_tags "$file" "$tags" + write_tags "$file" "$global_tags" "$tags" echo "done." >&2 ;; :*) if [ -n "${file:-}" ]; then - write_tags "$file" "$tags" + write_tags "$file" "$global_tags" "$tags" echo "done." >&2 tags='' fi @@ -157,8 +162,14 @@ filename_new="${line#* }";; *=*) - tags="${tags:+$tags -}$line";; + if [ -z "${file:-}" ]; then # global scope + global_tags="${global_tags:+$global_tags +}$line" + else # file scope + tags="${tags:+$tags +}$line" + fi + ;; *|'#*') :;; esac