Todd Slater wrote:

On Thu, Oct 30, 2003 at 07:50:44PM +0200, Anarky wrote:


Todd Slater wrote:


Seriously, there could be some limitations depending on your view.

1. You're going lossy to lossy so quality will be degraded
2. You *may* lose ID3 tags
3. Depending on how many mp3's you have, it could take a loooong time

Google for mp32ogg and see what you come up with.





yes, but that program only does 1 file at a time .. I'm talking about batch converting everything. I'd be willing maybe to accept the losses :)



OK, here you go. As an added bonus, it keeps ID3 tags. Requires mpg123 to convert to wav, mp3info to read id3 tags, and of course oggenc.

Todd


------------------------------------------------------------------------

#/bin/bash
# ommtoc one more mp3 to ogg converter
# remember, lossy to lossy = lower quality sound
# this names ogg files to format:
# track# - title - album - artist.ogg
#
# requires mpg123
# requires mp3info
#
# not extensively tested!!
#
# SET UP VARIABLES
#
# top level directory to search (search is recursive)
searchPath="/home/you/mp3s"
#
# quality for ogg encoding
quality=3
#
# remove wav file? yes/no
rmWav=yes
#
# remove original mp3? yes/no
rmMp3=no
#
# no more variables!
#
# find all mp3's
find "$searchPath" -type f -iname '*.mp3' > mp3list
while read mp3
do
workingPath=`dirname "$mp3"`
wavName=`basename "$mp3"|sed s/\.[mM][pP]3/\.wav/`
testID3=`mp3info -p %t "$mp3"`
if [ -z "$testID3" ] ; then
noID3Name=`basename "$mp3"|sed s/\.[mM][pP]3/\.ogg/`
echo "Converting '$mp3' to wav..."
mpg123 --wav "$workingPath/$wavName" "$mp3" >/dev/null 2>&1
echo "Encoding "$wavName" to ogg..."
oggenc -q $quality -o "$workingPath/$noID3Name" "$workingPath/$wavName" >/dev/null 2>&1
if [ $rmMp3 = "yes" ] ; then
rm -f "$mp3"
fi
if [ $rmWav = "yes" ] ; then
rm -f "$workingPath/$wavName"
fi
else
album=`mp3info -p %l "$mp3"`
artist=`mp3info -p %a "$mp3"`
genre=`mp3info -p %g "$mp3"`
title=`mp3info -p %t "$mp3"`
track=`mp3info -p %n "$mp3"`
prettyTrack=`printf "%02d" $track`
year=`mp3info -p %y "$mp3"`
echo "Converting '$mp3' to wav..."
mpg123 --wav "$workingPath/$wavName" "$mp3" >/dev/null 2>&1
echo "Encoding "$wavName" to ogg..."
oggenc -q $quality -a "$artist" -N "$prettyTrack" -l "$album" -t "$title" -G "$genre" -d "$year" -n "$workingPath/$prettyTrack - %t - %l - %a.ogg" "$workingPath/$wavName" >/dev/null 2>&1
if [ $rmMp3 = "yes" ] ; then
rm -f "$mp3"
fi
if [ $rmWav = "yes" ] ; then
rm -f "$workingPath/$wavName"
fi
fi
done < mp3list
rm mp3list
echo Done!


wow!!!!!!!! thanks!!! I'm off to trying out to see if this script does the recursion too :) thanks a lot!


Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to