Re: Qs. about audacity and script to convert wav->mp3 or ogg

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

 



Maarten de Boer wrote:
1. I would like to export a number of wav files to mp3 files. Instead of doing it one by one from audacity, how can I export them using a shell script? I want to be able to set some basic tag info in a file and call that file to fill in the mp3 tags automatically. In essence, I want to call a script that converts all wav files in a directory to mp3 files. And of course, I would like to be able to set the bitrate in the script. Suggestions on which tool to use for this?

with bash, the following onelines does the trick:

for filename in *.wav; do lame $filename `echo $filename | sed s/wav$/mp3/`; done

ofcourse you can use all lame command line options. man lame will tell you
all.

(if you are not familiar with it, this may look a bit cryptical, but there
is nothing to it. the backticks mean: evaluate the expression within.
and the expression says: echo $filename | sed s/wav$/mp3/, which means: feed the filename to the regular-expression-based replacement, which replaces 'wav' at the end of the line ($) with 'mp3')

Thanks. I am quite familiar with Bash scripting. I was only wanting to get started on using the encoders in an automatic way.


2. I can export to ogg format from audacity. Can I do the same thing as (1) for this as well? Does ogg format support tags.

almost the same with oggenc, except oggenc wants the output file with -o

for filename in *.wav; do oggenc -o `echo $filename | sed s/wav$/mp3/` $filename; done

note that the above will fail if your filenames contain spaces.

I usually use quotes, e.g. for your command above:
$> for filename in *.wav; do oggenc -o `echo "$filename" | sed s/wav$/mp3/` "$filename"; done

but the above is not tested though; I make the filename in a different command and then call the file moving command, whatever that may be.

->HS



ls *.wav | while read filename;
instead of

for filename in *.wav
would deal with that.

but as always, there are many other ways to do the same thing. this is\
just how i would do it.

maarten




[Index of Archives]     [Linux Sound]     [ALSA Users]     [Pulse Audio]     [ALSA Devel]     [Sox Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux