Register
It is currently Sat Dec 20, 2014 3:40 am

BASH SCRIPT: Converting a directory of .wav files to .ogg


All times are UTC


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Mon Oct 25, 2004 4:12 am   
Site Admin
User avatar

Joined: Thu Apr 17, 2003 3:44 am
Posts: 12208
Location: Iowa
jbsnake.....

I'm sure you can improve this :) But I thought it was okay for my first attempt. I had some help from Isacklow , had to find a way to convert the incorrect naming extension ;)

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


saved on my system as wavtoogg.sh

run in the directory you need to convert.

_________________

Warlock (VmWare Workstation - Desktop)- Linux Mint 16 64-bit -- Cinnamon Edition.
VmWare 5.1.0 ESXI Hypervisor - I7-3770K/32GB ram.
Nas4Free - 6X3TB File Server.
Multiple ubuntu 64 bit servers on the ESXI machine.


Top
 Profile WWW  
 PostPosted: Fri Oct 29, 2004 12:00 pm   
Sr. Member

Joined: Wed Oct 15, 2003 5:12 pm
Posts: 1274
Location: Houston, TX
crouse: why not use that tgt= bit in your upper loop, and remove the lower loop entirely?


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 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:  
cron


Powered by phpBB © 2012 phpBB Group
© 2003 - 2012 USA LINUX USERS GROUP