Converting mp3 to wav

Hunter Kreie plug-discuss@lists.plug.phoenix.az.us
Wed, 30 Jan 2002 14:33:37 -0700


Nick,
I had the same concern. At first I thought "What about filenames containing
spaces? Each element will be treated as a different file." Correct me if I
am wrong, but I'm pretty sure the script Douglas wrote takes care of this.

>#!/bin/sh
>#
>ls *.mp3 | while read i
>    do
>        o=$(echo "$i" | sed -e "s/mp3/wav/")
>        mpg123 -b 10000 -s "$i" | sox -t raw -r 44100 -s -w -c2 - "$o"
>    done
>## eof

This pipes each line, rather than each element, of the output of ls to the
read command in the while. So if we had ./Bullet With Butterfly Wings -
Smashing Pumpkins.mp3, i="Bullet With Butterfly Wings - Smashing
Pumpkins.mp3" in the first iteration, rather than just "Bullet".

Good Job Doug!

Hunter Kreie

> -----Original Message-----
> From: plug-discuss-admin@lists.plug.phoenix.az.us
> [mailto:plug-discuss-admin@lists.plug.phoenix.az.us]On Behalf Of Nick
> Estes
> Sent: Wednesday, January 30, 2002 1:48 AM
> To: plug-discuss@lists.plug.phoenix.az.us
> Subject: Re: Converting mp3 to wav
>
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> >         o=$(echo "$i" | sed -e "s/mp3/wav/")
> >
> > This script lists the mp3 files in the current directory, converts the
> > mp3 extention to wav using sed, and then does the conversion.
>
> Be careful when using sed to change extensions, what if you have an mp3
> called something like "foo thump3.mp3", sed will turn it into "foo
> thuwav.mp3".  I know it's not as cool as using sed to do it, but basename
> generally leads to more consistent results in this case.
>
> o="$(basename $i .mp3).wav"
>
> 	--Nick
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: pgpenvelope 2.10.2 - http://pgpenvelope.sourceforge.net/
>
> iD8DBQE8V7NMv+hjYTGg7s4RAn8uAKCBGefIgeJOiLhgCmCBoSAdasOcKgCeJLV/
> lTbpopqxK/YQvHvSvIfLe5A=
> =T9kG
> -----END PGP SIGNATURE-----
>
> ________________________________________________
> See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail
> doesn't post to the list quickly and you use Netscape to write mail.
>
> PLUG-discuss mailing list  -  PLUG-discuss@lists.plug.phoenix.az.us
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss