Re: Re: flac rename

Differences between revision 727 and 729

for i in "$@"; do
    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

    TRACK=`metaflac --show-tag="TRACKNUMBER" $i | sed s/^.*=//`
    TRACK=`metaflac --show-tag="TRACKNUMBER" "$i" | sed "{ s/^.*=//; s/^0*//}"`
    TRACK=`printf "%02d" $TRACK`
    TITLE=`metaflac --show-tag="TITLE" $i | sed s/^.*=//`
    TITLE=`metaflac --show-tag="TITLE" "$i" | sed "{ s/^.*=//; s#/#-#g }"`

    mv $i "$TRACK - $TITLE.flac"
    TEMPLATE="$TRACK - $TITLE.flac"
done


    echo "$i -> $TEMPLATE"

    mv "$i" "$TEMPLATE"

done