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:

#!/bin/bash

# convert mp3 and wav to ogg
# copyright tonytraductor / http://www.BaldwinSoftware.com
# 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)
do
rename \ _ *.mp3
done

## and wavs

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

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)
do
n=$i
mpg123 -w “$n.wav” “$n”
done

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

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

# 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
do
oggenc $i
done

# 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!”

exit

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

Advertisements

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:

WordPress.com Logo

You are commenting using your WordPress.com 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: