Re: [linux-audio-user] Qs. about audacity and script to convert wav->mp3 or ogg

From: Maarten de Boer <mdeboer@email-addr-hidden>
Date: Mon Feb 19 2007 - 23:45:11 EET

> 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')

> 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.

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
Received on Tue Feb 20 00:15:07 2007

This archive was generated by hypermail 2.1.8 : Tue Feb 20 2007 - 00:15:07 EET