Mikkel L. Ellertson wrote:

I like to make scripts a bit more "bullet proof"... I would probably change it to:

for i in *.mp3 ; do
   name=$(basename "$i" .mp3)
   mpg123 -s "$name.mp3" | sox -f 44100 -w -s -c 2 - "$name.wav"
done

This way, it handles files with spaces in the name, and you avoid having to use a temp file. The error generated by a file with a space in its name would not be a problem by itself, and using a temp file would not be a problem by it self. but if you get the wrong name, you could delete something other then what you intended to. For example, if you had a file called "bridge over troubled water.mp3" and you also had a file called "bridge" in the same directory, you script would first overwrite, then delete "bridge". Using "basename" in place of "FILE=`echo $FILE | sed s/.mp3//g`" also solves the problem of a file with ".mp3" in more then one place in the name. It would probably not be a problem in any case, but you never know.

Mikkel

You are a scriptmaster of note, Mikkel. My version of the script works for me, because I always make sure that there are no spaces in the names first. Your refinement allows one to be more lazy!


regards
Duncan


____________________________________________________
Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com
Join the Club : http://www.mandrakeclub.com
____________________________________________________

Reply via email to