rendered paste body#!/bin/bash# cue2mp3 by jipe <jipe@users.sourceforge.net># a simple shell script to handle audio files according to the informations contained in a ".cue" file# requires mpgtx, lame, mac, and flac# supported audio formats are ape, mp3 and flac# other formats can be added if required, just ask me, or do it yourself :)# this script is under the Gnu Public Licence v3.0 <http://www.gnu.org/licenses/gpl-3.0.txt>case $1 in -h|-help) echo "usage: cue2mp3 [ ape | flac | mp3 | -h | -help ] file.cue"; exit 0 ;; esacwhich mpgtx &>/dev/null || { echo requirement: mpgtx missing; exit 64; }which lame &>/dev/null || { echo requirement: lame missing; exit 64; }FORMAT=$1shiftNAME="${@%.cue}"[[ -e "${NAME}.${FORMAT}" ]] || { echo "${NAME}.${FORMAT}" doesn\'t exist; exit 63; }title () { n=1 grep " TITLE" "${NAME}".cue | while IFS='"' read a b c; do N=$(printf "%02d" $n) if [ -e chunk-"$n".mp3 ]; then mv chunk-"$n".mp3 "$N - ${b//\//-}.mp3" else mv chunk-"$N".mp3 "$N - ${b//\//-}.mp3" fi ((n++)) done}splittracks () { count=1 grep "INDEX 01" "${NAME}".cue | while IFS=$' \t\n\r:' read a b c d e f; do track="$c:$d.$e" if ((count==1)); then printf "[-" else printf "${track}] ]${track}-" fi ((count++)) done printf "]"}case $FORMAT in ape) which mac &>/dev/null || { echo requirement: mac missing; exit 64; } mac "${NAME}".ape "${NAME}".wav -d lame -b 320 -m j "${NAME}".wav "${NAME}".mp3 rm -f "${NAME}".wav mpgsplit "${NAME}".mp3 $(splittracks) rm -f "${NAME}".mp3 ;; mp3) mv "${NAME}.mp3" tmp.mp3 lame -m j --resample 44.1 -b 320 --mp3input tmp.mp3 "${NAME}.mp3" mpgsplit "${NAME}".mp3 $(splittracks) rm -f "${NAME}".mp3 mv tmp.mp3 "${NAME}.mp3" ;; flac) which flac &>/dev/null || { echo requirement: flac missing; exit 64; } flac -d "${NAME}".flac lame -b 320 -m j "${NAME}".wav "${NAME}".mp3 rm -f "${NAME}".wav mpgsplit "${NAME}".mp3 $(splittracks) rm -f "${NAME}".mp3 ;; *) echo "usage: cue2mp3 [ ape | flac | mp3 | -h | -help ] file.cue" ;;esac titleexit 0