tonybaldwin | blog

non compos mentis

Oggify… converting all your wav and mp3 to ogg

leave a comment »

I have too many wav and mp3 files, really.
I mean wav files are BIG.
And mp3 files suck, and are a proprietary format.
So, I wanted to convert ALL of my tunes to ogg-vorbis format,
a lossless open source audio file format.

So, I wrote this:


# convert mp3 and wav to ogg
# copyright tonytraductor /
# released under the terms of the Gnu Public License v.2 or later.
# no promises…if it breaks something, call your mom…

echo “Oggify, at your service.”

# removing spaces in names or
## mp3s

echo “Removing spaces in names…”

for i in $(ls -1 *.mp3)
rename \ _ *.mp3

## and wavs

for i in $(ls -1 *.wav)
rename \ _ *.wav

echo “Converting mp3 files to wav…”

# converting all mp3 files to wav,
#so there will be nothing but wavs

for i in $(ls -1 *.mp3)
mpg123 -w “$n.wav” “$n”

# stripping the .mp3 extension from filename.mp3.wav

for i in $(ls -1 *.wav)
rename .mp3. . *.wav

# clean up as we go

rm -f *.mp3

# and, now, converting those wav files to ogg

echo “Converting wav to ogg…”

for i in *.wav
oggenc $i

# more clean up

echo “Removing mp3 and wav files…”

# removing all those big, fat wav files.

rm -f *.wav

echo “Your oggs are all fresh and toasty and ready to enjoy, friend.”
echo “Happy listening!”


I had written a gui version, too, with zenity, but, bah…
Who needs a gui?


Written by tonybaldwin

September 1, 2008 at 6:23 pm

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: