tonybaldwin | blog

non compos mentis

Oggify (improved)

with one comment

Aside from any argument over which audio file format is best (I like FOSS, thus ogg), I reworked my oggify script, attempting to implement what I learned from comments at


#!/bin/bash

# convert mp3 and wav to ogg
# tonytraductor / http://www.BaldwinSoftware.com

echo -e “Oggify, at your service.\nOggify will convert all mp3 and wav files in this directory to ogg files, and REMOVE the old mp3 and wav files.\nFirst, it will make all file extensions lower case, and remove spaces from the file names.\n\nDo you wish to continue? (type y to continue)”

read ans

if [ $ans == y ]; then

echo “Removing spaces in names, and removing capitals from file extensions…”

##
# Note: Ubuntu users (possibly any deb based distro?) will have to alter the rename command to
# rename ‘s/\ /_/’ *.(file extension)

# make extensions all lower case

for i in *.MP3
do
rename MP3 mp3 *.MP3
done

for i in .WAV
do
rename WAV wav *.WAV
done

# remove spaces in names

for i in .mp3
do
rename \ _ *.mp3
done

for i in *.wav
do
rename \ _ *.wav
done

echo “Converting mp3 files to wav…”

# converting all mp3 files to wav,
# so there will be nothing but wavs
# DELETING the mp3 files as soon as the wav is completed

for i in *.mp3
do

n=$i

echo “Converting $n to wav…”

mpg123 -w “$n.wav” “$n”

echo “Stripping mp3 extension from wav file name…”

rename .mp3. . $n.wav

echo “Removing mp3 file…”

rm $n

done

# and, now, converting those wav files to ogg
# DELETING wav files after oggs are created

echo “Converting wav files to ogg…”

for i in *.wav
do
n=$i
oggenc $n

echo “Ogg created, removing wav file…”

rm $n

done

# more clean up

echo -e “Your oggs are all fresh and toasty and ready to enjoy, friend.\nHappy Listening!”

exit

else

echo -e “Oh..okay…Ogg files are an excellent audio file format, though.\nYou can learn more about them at http://www.vorbis.com\nB’bye now…”

fi

exit

# This program was written by tony baldwin – tonytraductor@linguasos.org
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Advertisements

Written by tonybaldwin

September 4, 2008 at 11:56 pm

One Response

Subscribe to comments with RSS.

  1. I really like coming to your website. Thank you for this post, since it has been very helpful. I have a site where I have numerous music jobs posted for searching, and would like to link to your blog.

    Music Jobs

    May 4, 2011 at 8:55 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: