Created
October 6, 2012 12:14
-
-
Save makotom/3844764 to your computer and use it in GitHub Desktop.
Create MPEG-4 Audio files from CUE sheet music
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 | |
if [ $# -lt 1 ] | |
then | |
exit | |
fi | |
cue_file=$1 | |
wav_file=$(cat $cue_file | grep FILE | sed -e "s/^FILE \"\(.*\)\".*$/\1/") | |
cuebreakpoints "$cue_file" | shntool split "$wav_file" | |
find -name "split-*.wav" -exec neroAacEnc -cbr 512000 -if {} -of {}.m4a \; | |
ntrack=$(cueprint -d "%N" "$cue_file") | |
trackno=1 | |
fields="TITLE ALBUM ARTIST COMMENT GENRE TRACKNUMBER" | |
TITLE="%t" | |
ALBUM="%T" | |
ARTIST="%p" | |
COMMENT="%c" | |
GENRE="%g" | |
TRACKNUMBER="%n" | |
for file in $(ls split-*.m4a) | |
do | |
for field in $fields | |
do | |
value=$(cueprint -n $trackno -t $(eval echo \$$field) "$cue_file") | |
if [ -n "$value" ] | |
then | |
case $field in | |
TITLE) | |
mp4tags -s "$value" "$file" | |
title="$value" | |
;; | |
ALBUM) | |
mp4tags -A "$value" "$file" | |
;; | |
ARTIST) | |
mp4tags -a "$value" "$file" | |
;; | |
COMMENT) | |
mp4tags -c "$value" "$file" | |
;; | |
GENRE) | |
mp4tags -g "$value" "$file" | |
;; | |
TRACKNUMBER) | |
mp4tags -t "$value" "$file" | |
;; | |
esac | |
fi | |
done | |
if [ -n "$title" ] | |
then | |
mv "$file" $(if [ $trackno -lt 10 ]; then echo 0; fi)$trackno" - $title".m4a | |
fi | |
trackno=$(($trackno + 1)) | |
done | |
rm split-*.wav |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment