Skip to content

Instantly share code, notes, and snippets.

@yock
Created March 13, 2011 01:24
Show Gist options
  • Save yock/867769 to your computer and use it in GitHub Desktop.
Save yock/867769 to your computer and use it in GitHub Desktop.
Script to burn a seamless audio CD from a directory of mp3 and/or mp4 files
#!/bin/bash
function append_filename {
echo -en >> $TOCFILE "TRACK AUDIO\nFILE \"$WAV\" 0\n"
}
MP3DIR=$1
TOCFILE="cd_$$.toc"
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
echo "CD_DA" > $TOCFILE
for i in `find "$MP3DIR" | sort`
do
TYPE=`file -b --mime-type $i`
WAV="`basename $i`.wav"
if [ $TYPE == "audio/mp4" ]
then
faad $i -o $WAV
append_filename
elif [ $TYPE == "audio/mp3" ]
then
mpg123 -w$WAV $i
append_filename
fi
done
echo -e "TOC file available at $TOCFILE"
cdrdao write $TOCFILE
IFS=$SAVEIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment