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

Simon Stewart sms at lateral.net
Fri Feb 15 11:00:53 UTC 2002


On Thu, Feb 14, 2002 at 08:42:45PM +0000, Nick Hill 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
> 
> Any ideas?
> 
> It could possibly be written as a shell script but this would be wasteful if a command exists to do something similar already.

Chuck the command line in a script, make it executable and run
something like:

find . -name "wildcard*" -print -exec shell_script.sh {} \;

This runs "shell_script.sh" once for every time find discovers
something that matches the wildcard.

The only reason to use a script is that I've found find to prefer only
executing one command at a time, rather than a string of them.

Cheers,

Simon

-- 
"... it is important to realize that any lock can be picked
with a big enough hammer." -- Sun System & Network Admin manual

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




More information about the GLLUG mailing list