[NTLUG:Discuss] Trivial MP3 conversion script

Ralph sfreader at sbcglobal.net
Sat Jun 14 05:32:02 CDT 2008


Howdy,
  I had meaning to write a little script like this for a while.  There
seems to be a variety of ways it can be accomplished.  I tried out
variations on all the ways suggested and here is what I came up with.  I
have used this and it works.  Mine starts with wav files, since that is
what lame is expecting.  The script is 4 lines long, and line 3 is long.
I am sure it can be improved.
$ cat ./mp3ify.sh 
#!/bin/sh
for i in *.[w][a][v]; do
 lame -m m --replaygain-accurate --verbose -q 0 --cbr -b 32 --resample
22.05 $i ${i%%.wav}.mp3;
 done


On Sat, 2008-06-07 at 15:30 -0500, Stuart Johnston wrote:
> Daniel Hauck wrote:
> > I did this:
> > 
> > for i in *.[Ww][Mm][Aa]; do lame $i ; done
> > 
> > 
> > The intent and purpose is to convert all WMA files in a folder over to
> > MP3.  It works, but it leaves "wma" in the resulting filename.
> > 
> > For example, there is a file called "song.wma" and I run lame against
> > it, the resulting output file is "song.wma.mp3"
> > 
> > How can I take the extension off of the file list and then process like
> > this?
> > 
> > ... do lame $i.[Ww][Mm][Aa] $i.mp3; done
> > 
> > What magic code strips off the ".wma"?
> 
> 'basename' will strip off the directory path and optionally the 
> extension.  Something like this:
> 
> do lame $i.[Ww][Mm][Aa] `basename $i wma`mp3; done
> 
> The suffix for basename is case sensitive though so perhaps something 
> with sed:
> 
> do lame $i.[Ww][Mm][Aa] `echo $i | sed 's/[Ww][Mm][Aa]//'`mp3; done
> 
> Probably better solutions out there.
> 
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss




More information about the Discuss mailing list