I am writing a simple script which creates a folder tree. So far so good. However, I need the permissions to enable both the group and others to read & write. As it stands, my folder tree creates perfectly, but when I try to change permissions, my script runs into terrible problems. I run aground right at the first line (set new_folder to POSIX path of (item i of jobFolder)) and advice would be much appreciated. The only way I can think of to do this is through the shell, is there a property for permissions that I could simply apply to the folders as I create them?
Thanks,
Don
display dialog "Enter the job number:" default answer "U07MM0"
set jobNumber to text returned of result
tell application "Finder"
activate --bring finder to the front
set chosenFolder to (choose folder with prompt "Please select the destination folder.") --asks user where to put it
make folder at chosenFolder with properties {name:jobNumber}
set jobFolder to result
--creates top folder
make folder at jobFolder with properties {name:jobNumber & "_XML"}
make folder at jobFolder with properties {name:jobNumber & "_ISSUE"} -- creates issue folder
set issue to result -- gives a name to the "issue" folder just created
tell application "Finder"
make folder at issue with properties {name:jobNumber & "_MANUSCRIPTS"}
make folder at issue with properties {name:jobNumber & "_PDF-PS"}
set pdfps1 to result
make folder at pdfps1 with properties {name:"f2"}
make folder at issue with properties {name:jobNumber & "_SOURCE"}
end tell
make folder at jobFolder with properties {name:jobNumber & "_REPRINTS"} --creates reprints folder
set reprints to result
make folder at reprints with properties {name:jobNumber & "_PDF-PS"}
set pdfps to result
make folder at pdfps with properties {name:"f2"}
make folder at pdfps with properties {name:"p2"}
make folder at pdfps with properties {name:"s2"}
make folder at reprints with properties {name:jobNumber & "_SOURCE"}
--here is where we try to change permissions
repeat with i from 1 to (count of jobFolder)
-- Format path for use in shell script
set new_folder to POSIX path of (item i of jobFolder)
set shell_script_chown to "sudo chown -R root:admin "
-- Change mode of folder to rwxrwxr-x
set shell_script_chmod to "sudo chmod -R 775 "
-- Perform both shell scripts
repeat with this_shell_script in {shell_script_chown, shell_script_chmod}
try
do shell script this_shell_script & new_folder as string
display dialog ("item " & i & " of " & (count of jobFolder) & return & this_shell_script & new_folder as string) giving up after 1
on error error_message number error_number
-- If error occurs beep user and bring up why there was an error
beep
display dialog ("Error number: " & error_number & return & error_message as string) giving up after 5
end try
end repeat
end repeat
end tell
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)