3 # Copyright (C) 2009 Nick Bowler
5 # Adds replaygain tags to the flac files in a directory. Assumes that all
6 # the tracks from a CD are located in the same directory. Unless the -f flag
7 # is specified, directories already containing replaygain tags will not be
10 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
11 # This is free software: you are free to do what the fuck you want to.
12 # There is NO WARRANTY, to the extent permitted by law.
14 alias flactags='metaflac --export-tags-to=-'
19 [[ -d $1 ]] || return 1
22 [[ $#files > 0 ]] || return 1
30 (flactags $i | grep -q REPLAYGAIN_REFERENCE) || return 1
35 while getopts 'f' opt $@; do
44 if [[ $# == 0 ]]; then
45 printf 'usage: %s [-f] directory [directory ...]\n' $0
52 if ! is_disc_dir $dir; then
53 printf 'not an album directory, skipping.\n'
57 if [[ $force == 0 ]] && has_replay_gain $dir; then
58 printf 'already done, skipping.\n'
62 metaflac --add-replay-gain $dir/*.flac