Home
July 2009   01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
megreen

Oggify... converting all your wav and mp3 to ogg

Posted on 2008.09.01 at 18:23
Current Music: cabezones
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?

Previous Entry  Next Entry