If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Welcome to Mac-Forums! Join us to comment and to customize your site experience! Members have access to different forum appearance options, and many more functions.

Hello again. I have looked far and wide for an answer to this one, but to no avail.

It's a syntax question ... I am trying to refer to a variable in a nested loop ( for loop inside a for loop)
I have a script to automate the creation of a directory structure. Quite a simple script actually. Just using Arrays to define the hard coded directory name suffixes within the script and asking for interactive input for directory name prefix that will be standard across entire tree and finally mkdir builds the tree.

########## Arrays of directory names############
### Here are the arrays where I hard code the directory suffixes:
### Array of folders to be made in the main directory
dir0=( Account Web Print )
### Arrays of folders to be placed in the above subdirectories
sub1=( Art Code )
### Arrays of folders to be placed in the above subsubdirectories
sub1sub0=( Photoshop Illustrator )
########### The function to build the directories ############
## Excluded mkdir commands for the sake of getting this working first.
function createdirectories ()
{
#would make main dir here then run following loop for subdirectories
echo "adding dir Main"
for md in 0 1 2 3 4
do
echo "adding dir ${dir[$md]}"
for sd in 0 1 2 3 4
do
echo "adding dir ${sub{$md}[$sd]}"
for ssd in 0 1 2 3 4
do
echo "adding dir ${sub{$md}sub{$sd}[$ssd]}"
done
done
done
}

And a last question:

I feel silly having to define the length of the loop manually when it seems that I should be able to just run it for the length of the array. Is this possible in tsch scripting?

Thanks for any direction,

Lizard

Oh, another last thing. In my research I keep coming across comparisons between csh/tcsh and bourne shell scripting languages. Should I switch to Bourne or Korn? Are they better in the long run? I'm running Mac OS X.3. My main programming experience is in Actionscript for Flash and some PHP. I am just now digging into these shell scripting languages.