Skip to content

Instantly share code, notes, and snippets.

@colin-axner
Forked from sillage/flactags.sh
Last active April 16, 2020 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colin-axner/cad4a130bfbdfe38d14f4b859c1681ad to your computer and use it in GitHub Desktop.
Save colin-axner/cad4a130bfbdfe38d14f4b859c1681ad to your computer and use it in GitHub Desktop.
flac tags with metaflac
#!/bin/bash
# file format: ARTIST/ALBUM/01-TITLE.flac
# name of file for the cover art
read -p "ART " ART
read -p "GENRE? " GENRE
read -p "TOTAL TRACKS? " TRACKTOTAL
read -p "YEAR? " -n 4 YEAR
ALBUM="${PWD##*/}" # ALBUM=$(basename "${PWD}")
ARTIST=$(echo $(cd .. && echo "${PWD##*/}"))
# delete all
metaflac --preserve-modtime --remove-all-tags *.flac
# artist, album, year and cover
metaflac --preserve-modtime --set-tag=ARTIST="${ARTIST}" --set-tag=ALBUM="${ALBUM}" --set-tag=DATE=${YEAR} --set-tag=GENRE=${GENRE} --set-tag=TRACKTOTAL=${TRACKTOTAL} --import-picture-from=${ART} *.flac
# using input redirection and process substitution (!) to manage punctuation and spaces
# TRACKNUMBER
while read file;
do
# only keep tracknumber before `-'
metaflac --preserve-modtime --set-tag=TRACKNUMBER=${file%%-*} "${file}";
done < <(ls *.flac)
# TITLE
while read file;
do
TITLE="${file#*-}"; # remove tracknumber
TITLE="${TITLE%.flac}"; # remove extension
metaflac --preserve-modtime --set-tag=TITLE="${TITLE}" "${file}";
done < <(ls *.flac)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment