Register
It is currently Fri Oct 24, 2014 8:42 am

Converting a directory of .wav files to .ogg


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Tue May 17, 2005 8:01 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 669
Location: Des Moines, Iowa
Reposted from: http://usalug.org/phpBB2/viewtopic.php?t=4415

Converting a directory of .wav files to .ogg
Code:
#!/bin/bash
# WAVtoOGG Converter
# Converts .wav files to .ogg files.
for i in *.wav ; do oggenc -o $i.ogg $i ; done
# Below converts the incorrect naming extension
# From .wav.ogg to just .ogg
badextension="*.wav.ogg";
match=".wav.ogg";
replacewith=".ogg";
for i in $( find -iname "$badextension" );
do
src=$i
tgt=$(echo $i | sed -e "s/$match/$replacewith/")
mv $src $tgt
done


Top
 Profile WWW  
 PostPosted: Fri Sep 09, 2005 11:48 pm   

Joined: Sat Jun 04, 2005 3:16 am
Posts: 16
Location: That Lunar Colony That Everybody Denies the Existance of.
You can do the 2nd part of your script with the rename command, it's sed-like

rename '{ s/wav.ogg$/ogg/ }'

the wav.ogg$ here $ means end of file pretty much assures you only get the unneeded .wav near the end of the filename, and not wav imbeded in other words like wave.... I forget if you need to escape the $ with a \ but I don't think you do......

the g is very helpful in other task :

rename '{ s/ //g }' * removes all the spaces in a filename, the g means to run it again and again like in sed.


Top
 Profile  
 PostPosted: Sat Sep 10, 2005 3:12 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 669
Location: Des Moines, Iowa
:) Thanks, I hadn't played with the rename command before..... nice.


Top
 Profile WWW  
 PostPosted: Mon Aug 28, 2006 11:55 pm   
User avatar

Joined: Fri Jul 21, 2006 9:11 am
Posts: 3
Location: /mnt/earth/ru/spb
crouse wrote:
Reposted from: http://usalug.org/phpBB2/viewtopic.php?t=4415

Converting a directory of .wav files to .ogg
Code:
#!/bin/bash
# WAVtoOGG Converter
# Converts .wav files to .ogg files.
for i in *.wav ; do oggenc -o $i.ogg $i ; done
# Below converts the incorrect naming extension
# From .wav.ogg to just .ogg
badextension="*.wav.ogg";
match=".wav.ogg";
replacewith=".ogg";
for i in $( find -iname "$badextension" );
do
src=$i
tgt=$(echo $i | sed -e "s/$match/$replacewith/")
mv $src $tgt
done

find * -name '*.wav' -exec oggenc -o `echo '{}' | sed -e "s/.wav$//"`.ogg '{}' \;


Top
 Profile ICQ  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP