[Gllug] A command to repeat a function for each file
Nick Hill
nick at nickhill.co.uk
Thu Feb 14 22:24:18 UTC 2002
On Thu, 14 Feb 2002 20:52:24 -0000
"Darran D. Rimron-Molloy" <ddrm at digital-science.net> wrote:
> >
> > 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.
Looks good, although I would like a general purpose script which I could pass parameters to from the command line. I often have use for such a script, which is why I thought it had been implemented as a common function.
Regards
Nick.
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list