[Gllug] A command to repeat a function for each file

Darran D. Rimron-Molloy ddrm at digital-science.net
Thu Feb 14 20:52:24 UTC 2002


> -----Original Message-----
> From: gllug-admin at linux.co.uk
> [mailto:gllug-admin at linux.co.uk]On Behalf
> Of Nick Hill
> Sent: 14 February 2002 20:43
> To: gllug at linux.co.uk
> Subject: [Gllug] A command to repeat a function for each file
>
>
> I am looking for a command to repeatedly run sox for each
> file matching a wildcard.
>
> Eg
> if function is foobar and input file is %1 and output file name is %2
>
> foobar 'sox %1 -r 11025 %2 resample' *.wav *11025.wav
>
> so that each file.wav gets re-sampled and written as file11025.wav

for infile in *.wav
do
	outfile=`echo $infile|cut -f1 -d"."'-11025.wav
	echo "Resampling \"$infile\" to \"$outfile\""
	sox $infile -r 11025 $outfile resample   [or whatever it is]
done

Will not be happy file filenames with .'s (except to mark the
extention) - I could fix these limitations, (with perl, to be the
fastest, but I hate perl :) ) but I'm a fat lazy pig, and I like shell.

	-Darran


-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list