I’m trying to build on this script and let it ask for the location of the text file and the location the folders will be built.Just trying to clean this up so others at my place can use it. I keep getting an error on POSIX that the file doesn’t exist. To test this I have a text file named test.txt at the root of Macintosh HD and I tried entering Macintosh HD/test.txt and Macintosh HD:test.txt and both give the error.
This is to build Home folders. I’d also like to have it add a folder named Documents within this folder if it can be done easily but I haven’t a clue how.
I have given up on using chown to change the folder name to the owner because the users don’t exist in the local user database but in LDAP.
I haven’t written scripts since QuarkXpress in 95 and I’m losing hair fast cause lots of things have changed
thanks for the help, the original script which works is at the bottom as well.
property filelocation : “file location”
property folderlocation : “folder location”
display dialog “Enter location of text file:” default answer “”
set “filelocation” to text returned of result
set namedoc to do shell script “cat "” & (POSIX path of file “filelocation”) & “"”
display dialog “Enter location of Home folders” default answer “”
set folderlocation to text returned of result
set fold to “folderlocation”
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 -p "” & fold & this_item & “"”
end repeat
display dialog “Done!”
Original script
set namedoc to do shell script “cat "” & (POSIX path of file “OS X Server:usernames.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 & “"”
do shell script “chown "” & this_item & " " & fold & this_item & “/” & “"” with administrator privileges
do shell script “chown :!PupilOwner "” & fold & this_item & “/” & “"” with administrator privileges
end repeat
display dialog “Done!”