Oggify (improved)
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 here.
#!/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 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.
#!/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 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.
