[Techtalk] recording music CDs- batch conversions

Carla Schroder carla at bratgrrl.com
Tue Mar 9 08:32:26 EST 2004


On Tuesday 09 March 2004 4:57 am, dominik.schramm at gmxpro.net wrote:
> for i in *.au
> do
>         FILE=${i%.au}
>         echo $FILE
>         sox ${FILE}.au ${FILE}.cdr
>         sox ${FILE}.cdr ${FILE}.wav
> done
> 
> The ${i%xyz} notation cuts off "xyz" from the right side of $i.
> cut -d. -f1 returns everything up to the first dot. If there 
> are multiple dots in the file name, it fails.
> 

You're almost there, this is what I came up with:

$ for i in *.wav ; do echo $i ; sox $i ${i%%.wav}.cdr ; echo sox $i 
${i%%.wav}.cdr; done

You need i%%.wav to remove the wav extension. 

Here's a little script I hacked up to convert wavs to oggs, and move the oggs 
into a separate directory:

 #!/bin/bash
 # a simple script for converting wav files
 # to ogg format, and moving the ogg files
 # into a separate directory
 # first, our directory variables
 OGGDIR=~/TMP/oggfiles
 WAVDIR=~/1wavtest

 #change to directory the wavs are in
 cd $WAVDIR
 
 # use sox for the file conversion
 # all wavs in the directory are selected
 for i in *.wav ;
 do echo $i ;
 sox $i ${i%%.wav}.ogg ;
 echo ${i%%.wav}.ogg;
 done
 
 #check to see if the ogg directory exists
 if [ -e $OGGDIR ]
 then
 echo "The ogg directory exists, and the ogg files will be moved into it."
 mv *.ogg $OGGDIR
 
 # create it if it's not already present
 else
 echo "The ogg directory does not exist, so I will create it."
 mkdir -p $OGGDIR
 mv *.ogg $OGGDIR
 echo "All finished, enjoy your music."
 fi 

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~
Carla Schroder
www.tuxcomputing.com
this message brought to you
by Libranet 2.8 and Kmail
~~~~~~~~~~~~~~~~~~~~~~~~~



More information about the Techtalk mailing list