Re: Batch conversion WAV-MP3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



However, lame doesn't seem to want to accept wildcards. Am I doing something wrong? if so, is there another program that will do the job?

Well, if Lame is being lame, so to speak, you can always use either a bash "for" loop or the "find" command to pass each file name individually to lame. I don't know the transcoding parameters to lame, but assuming you convert foo.wav into foo.mp3 by simply calling "lame foo.wav", you can do it either of the following ways:

bash>  for F in *.wav; do lame $F; done

or

bash>  find . -name "*.wav" -exec lame {} \;

(note the escaping of the semi-colon in the "find" version).  The
two are fairly functionally equiv, except that if you have
bajillions of files, you might run up against Bash's globbing
limits in the "for" version, which are avoided by using the
"find" version.  Additionally, the "find" version will go into
subdirectories.  That may or may not be what you want...if not,
find has a "-maxdepth" argument which you should be able to set
to zero to prevent this behavior.

If "lame" requires you to pass both the .wav name, and the mp3
name, you can do it with the following:

find . -name "* *" | sed -e 's/ /\\ /g' -e 's/\(.*\).wav/lame
\1.wav \1.mp3/' | sh

(note, that's all one line)  The first sed command escapes any
spaces in the file-name/path while the second sed command strips
the .wav extension, and converts it into the "lame" command with
the filename.wav and the filename.mp3  At this point, you then
have the output being a series of "lame" commands, so you just
pipe the results to "sh" to run them and you're good to go.

To change parameters to "lame", just modify that second sed
parameter to something like

 's/\(.*\).wav/lame --abr 112 \1.wav \1.mp3/'

which should do the trick.

Hope this helps.

-tim




_______________________________________________ Blinux-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/blinux-list

[Index of Archives]     [Linux Speakup]     [Fedora]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]