[Gllug] A command to repeat a function for each file
Jonathan Harker
jon at jonathanharker.co.uk
Thu Feb 14 23:32:51 UTC 2002
On Thursday 14 February 2002 22:24, Nick Hill wrote:
<snip>
> 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.
I'm pretty sure there isn't a shell function/program/script to do that. You
could get close by using the rename command and doing something like
#!/bin/sh
for f in $1; do
sox $f -r 11025 $f.RENAME resample
rename $2 $3 $f.RENAME
done
which takes 3 arguments. For example,
resample *.wav ".wav" "-11025.wav"
would resample the *.wav files one by one and rename them to *-11025.wav -
perhaps a variation of this is what you're after. But to do a generic call of
foo, like
somescript foo oldfiles newfiles
you'd have to invent a parameter substitution scheme for the foo parameter
and then sed/awk your $2 and $3 into it. Doable, but really a reinvention of
the ` substitution character and for .. in .. do loops. "I see parameters
within parameters... I see two great houses..." (woah sorry, it's late)
HTH,
Jon.
--
Jonathan Harker
Web: www.jonathanharker.co.uk
ICQ: 30647378
MSN Messenger: jonathanischoice at hotmail.com
Yahoo & AIM chat: jonathanischoice
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list