rendered paste body#!/bin/bash # mp3tom4a.sh # bulk mp3 to m4a converter to generate bookmarkable aac files #requires mplayer, id3v2, aacplusenc and nokiatagger mp3files="*.mp3" wavend=wav aacend=m4a outdir=/media/Media/Music/M4A #change this for file in $mp3files do basenam=${file%.*3} # Get the first part of the filename, without the mp3 part mp3file=$file wavfile=${basenam}.$wavend aacfile=${basenam}.$aacend # Then run mplayer on the file, generating a wav file, using the mp3 file mplayer -vo null -vc null -ao pcm:fast:file="${wavfile}" "${mp3file}" id3v2 -C $file TITLE="`id3v2 -l $file | grep TIT2 | awk '{ORS=" "} {for (i = 4; i <= NF; i++) print $i}'`" ARTIST="`id3v2 -l $file | grep TPE1 | awk '{ORS=" "} {for (i = 4; i <= NF; i++) print $i}'`" ALBUM="`id3v2 -l $file | grep TALB | awk '{ORS=" "} {for (i = 4; i <= NF; i++) print $i}'`" TRACK="`id3v2 -l $file | grep TRCK | awk '{ORS=" "} {for (i = 6; i <= NF; i++) print $i}'`" YEAR="`id3v2 -l $file | grep TYER | awk '{ORS=" "} {for (i = 3; i <= NF; i++) print $i}'`" aacplusenc "${wavfile}" "${aacfile}" 64 nokiatagger -t "$TITLE" -a "$ARTIST" -y "$YEAR" -A "$ALBUM" "${aacfile}" # faac -b 96 -c 44100 --title "$TITLE" --artist "$ARTIST" --year "$YEAR" --album "$ALBUM" --track "$TRACK" -w -o ${aacfile} ${wavfile} rm "${wavfile}" mv "${aacfile}" "$outdir"