I wanted to convert my Itunes collection from my old mac to work on my FC10 box. I have posted here because this script does not quite work.
I have taken two other scripts from some this and other unix forums and almost made a recursive converter from what I saw in those.
At the moment the script sits at the root of the Music folder and when called by name it recursively works through the folder and converts the files at the end of the tree. (Currenlty it deletes intermediate files but not the original m4a files). It almost works(:-()
It would be more elegant to have a file in /usr/bin called m4a2mp3 or m4a2ogg which you gave a couple of parameters to and it then did its stuff.
Any takers?
Code:
#!/bin/sh
traverse()
{
for i in *
do
ls "$i"
done
if [ -d "$i" ]; then
cd "$i"
ls "$i"
traverse
else
cd "$i"
for j in *.m4a;
do
ls "$j"
faad "$j"
x=`echo "$j"|sed -e 's/.m4a/.wav/'`
y=`echo "$j"|sed -e 's/.m4a/.mp3/'`
faad -i "$j" 2>trackinfo.txt
title=`grep 'title: ' trackinfo.txt|sed -e 's/title" //'`
artist=`grep 'album: ' trackinfo.txt|sed -e 's/artist" //'`
album=`grep 'title: ' trackinfo.txt|sed -e 's/album" //'`
genre=`grep 'title: ' trackinfo.txt|sed -e 's/genre" //'`
track=`grep 'title: ' trackinfo.txt|sed -e 's/track" //'`
year=`grep 'title: ' trackinfo.txt|sed -e 's/year" //'`
lame --alt-preset 160 --tt "$title" --ta "$artist" --tl "$album" --tg "$genre" --tn "$track"$ --ty "$year" "$x" "$y"
rm trackinfo.txt
rm "$x"
done
fi
}