need to add to this script

I have a script that builds home folders from a text document. Several of you had input on this and it works well.

set namedoc to do shell script “cat "” & (POSIX path of file “OS X Server:staffnames.txt”) & “"”

set fold to “/Volumes/OS X Server/homes/”

repeat with i from 1 to number of paragraphs in namedoc
set this_item to paragraph i of namedoc
if this_item is “end” then exit repeat
do shell script “mkdir "” & fold & this_item & “"”
end repeat
display dialog “Done!”

The only problem is if it finds a folder already created, it stops and doesn’t go on.
How do I put a check in to see if the folder exists and only make it if necessary, skip it if its there? I don’t want to overwrite users data by forcing fresh folders down everytime I need to add 5-10 users.

thanks, I know you all will find a way!

Try using ‘mkdir -p’.

do shell script "mkdir -p \"" & fold & this_item & "\""


That worked like a champ, I can throw the list at the script and if a user needs a home folder its there with default permissions.

I really need to add a Documents folder within it and set permissions to make the folder name the owner but I can do that with HomeDirectoryHelper if I have to.