Last active
August 24, 2018 23:16
-
-
Save wgmyers/be64d22494c302f8a9675c5c4205a381 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# fix-beriah-flac.sh | |
# Bash shell script to fix tags in Book of Beriah flac zip | |
############ | |
# WARNING! # | |
############ | |
# | |
# USE OF THIS SCRIPT IS ENTIRELY AT YOUR OWN RISK! | |
# IT HAS BEEN TESTED ON PRECISELY ONE MACHINE ONLY. | |
# IT WORKS FOR ME. I HOPE IT WORKS FOR YOU. I DON'T KNOW. | |
# Instructions: | |
# Copy this script into the same directory as your humungous zip file of John Zorn goodness (HZFOJZG) | |
# Unzip the HZFOJZG | |
# Make the script executable and run it. | |
METAFLAC=metaflac | |
COVER_FILE=cover.jpg | |
# Enter the correct directory or abort if not found | |
cd 'The Book Beriah' || (echo "Can't find the 'Beriah' directory." && exit 1) | |
# Munge field separator so we can read directories with spaces in their names | |
SAVEIFS=$IFS | |
IFS=$(echo -en "\n\b") | |
ARTISTS=( | |
"Sofia Rei and J.C. Maillard" | |
"Cleric" | |
"Spike Orchestra" | |
"Julian Lage and Gyan Riley" | |
"Abraxas" | |
"Klezmerson" | |
"Gnostic Trio" | |
"Zion80" | |
"Banquet Of The Spirits" | |
"Secret Chiefs 3" | |
"Craig Taborn and Vadim Neselovskyi" | |
) | |
ALBUMS=( | |
"Book Beri’ah 1 Keter" | |
"Book Beri’ah 2 Chokhma" | |
"Book Beri’ah 3 Binah" | |
"Book Beri’ah 4 Chesed" | |
"Book Beri’ah 5 Gevurah" | |
"Book Beri’ah 6 Tiferet" | |
"Book Beri’ah 7 Netzach" | |
"Book Beri’ah 8 Hod" | |
"Book Beri’ah 9 Yesod" | |
"Book Beri’ah 10 Malkhut" | |
"Book Beri’ah 11 Da’at" | |
) | |
# Iterate over every directory | |
COUNT=0 | |
for dir in */; do | |
cd $dir | |
echo `pwd` | |
echo "Extracting cover image" | |
# Extract cover image from first file in directory | |
FIRST=01* | |
$METAFLAC --export-picture-to=$COVER_FILE $FIRST | |
# Fix ARTIST, ALBUMARTIST and ALBUM tags | |
echo "Fixing artist and album tags" | |
ARTIST=${ARTISTS[$COUNT]} | |
ALBUM=${ALBUMS[$COUNT]} | |
$METAFLAC --remove-tag="ARTIST" *.flac | |
$METAFLAC --set-tag="ARTIST=$ARTIST" *.flac | |
$METAFLAC --remove-tag="ALBUMARTIST" *.flac | |
$METAFLAC --set-tag="ALBUMARTIST=$ARTIST" *.flac | |
$METAFLAC --remove-tag="ALBUM" *.flac | |
$METAFLAC --set-tag="ALBUM=$ALBUM" *.flac | |
cd .. | |
COUNT=$((COUNT + 1)) | |
done | |
# Restore field separator | |
IFS=$SAVEIFS | |
echo "All done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Revision #1:
Revision #2: