[Malvern] Run a command recursivly in each folder?

Chris Eilbeck chris at yordas.demon.co.uk
Thu Sep 9 21:04:05 BST 2004


On Thu, Sep 09, 2004 at 08:49:51PM +0100, Robin Wilson wrote:
> Hi
> 
> That doesn't seem to work.
> 
> My file reads:
> 
> #!/bin/csh
> 
> foreach i (`find . -type d -print`)
> 
> /root/ogg2mp3
> 
> end
> 
> Any ideas?
> 
> If I just run /root/ogg2mp3 it works fine!

#!/bin/csh

foreach i (`find . -type d -print`)

	/root/ogg2mp3 $i

end

The loop will run for every directory below the current one the script is
run from ($i will contain the name of the directory).  I'm assuming
ogg2mp3 takes a directory name to convert.  If not you'd need to do
something like

#!/bin/csh

foreach i (`find . -type d -print`)

	( cd $i ; /root/ogg2mp3 )

end

which will temporarily change directory then run ogg2mp3

Chris
-- 
Chris Eilbeck                         mailto:chris at yordas.demon.co.uk
MARS Flight Crew                              http://www.mars.org.uk/
UKRA #1108 Level 2                                                UYB
TRA #9527                                                        PSMR



More information about the Malvern mailing list