Re: [linux-audio-user] converting large number of ogg's to mp3's

From: <mdeboer@email-addr-hidden>
Date: Sat Jan 08 2005 - 22:57:28 EET

>> sox /shared/music/albums/albumName/song.ogg ~/mp3/albumName/song.mp3
> [...]
> cd /shared/music/albums
> find . -name \*.ogg -print -exec sox {} {}.mp3 \;
>
> This will take any file under /shared/music/albums and create an mp3
> file with the same name plus a .mp3 extension.
> [...]

To change the extension, you could use sed.

find . -name "*.ogg" | while read filename; do \
  sox "$filename" "`echo $filename | sed -e 's/\.ogg$/.mp3'`" \
done

To explain this: the output of find will be feeded, line by line, to the
expression inside the while loop, setting the value of filename to each
line. The expression inside the ` ` will be evaluated first - it's
result is the value of $filename parsed by the regular expression that
replaces .ogg at the end of the line (end-of-line is represented by the
$ after ogg) with mp3.

Also note the use of "*" instead of \*, which I guess is a matter of
taste. Adding another | sed, you could easily substitute the folder as
well.

If you are not familiar with command-line scripting, this might all seem
a bit complicated, but once you get used to it, you'll see it's really
straightforward. And extremely powerful.

maarten
Received on Sun Jan 9 00:15:23 2005

This archive was generated by hypermail 2.1.8 : Sun Jan 09 2005 - 00:15:23 EET