I ran into a similar project a while back, and had to develop a project to make folder structures on 2 different different servers each with their own unique folder structure.
I went with the shell script: "do shell script (“mkdir -p”), I found it just a few seconds faster than “make new folder”
I also added in a feature from another script that will flush out all illegal characters as well as spaces and replace them with an underscore:
So if user inputs “XXXX XXXX 12$65”, the script will create “XXXX_XXXX_12_65”
I got alot of help from these forums to make this script happen, so here’s my compiled code
on run
--Make a choice for server folder type--
display dialog ¬
"What server folder do you need to make" buttons {"AD", "PrePress", "Cancel"}
set the button_pressed to the button returned of the result
--To make AD server--
if the button_pressed is "AD" then
set destination_ to (choose folder with prompt "Choose a destination for the job folder.") as string
set dd to (display dialog "Enter Your Job Number." default answer "XXXX_XXXX_12345")
set jobName to text returned of dd
set prefix_ to text -5 thru end of jobName & "_"
set subfolder_names to prefix_ & "{Old_QXD,ILL_EPS,PSD,Resources,EPS_TIF}" -- no spaces
set transmission_names to prefix_ & "Transmissions/{In,Out}" -- no spaces
set replace_strings to ¬
{" ", " ", "-", "_", "__", "~", "`", ":", ";", "!", "@", "â„¢", "'", "®", "#", "$", "?", "<", ">", "%", "^", "&", ¬
"*", "(", ")", "=", "+", "{", "}", "[", "]", "|", "\\", "/", "'", ",", "\""}
set astid to AppleScript's text item delimiters
repeat with this_replace_string in replace_strings
set jobName to my FixName(jobName, (contents of this_replace_string))
end repeat
set AppleScript's text item delimiters to astid
set jobFolderPOSIX to POSIX path of (destination_ & jobName) & "/"
do shell script ("mkdir -p " & jobFolderPOSIX & subfolder_names)
do shell script ("mkdir -p " & jobFolderPOSIX & transmission_names)
tell application "Finder" to update folder destination_
--To make PrePress server--
else if the button_pressed is "PrePress" then
set destination_ to (choose folder with prompt "Choose a destination for the job folder.") as string
set dd to (display dialog "Enter Your Internal Job Number." default answer "XXXX_XXXX_12345")
set fcbName to text returned of dd
set prefix_ to text -5 thru end of fcbName & "_"
set par to (display dialog "Enter The Client Job Number" default answer "XXXXXX")
set clientCode to text returned of par
set holdingfolder_names to prefix_ & "Holding/{Old,CompArt,Transmissions}"
set replace_strings to ¬
{" ", " ", "-", "_", "__", "~", "`", ":", ";", "!", "@", "â„¢", "'", "®", "#", "$", "?", "<", ">", "%", "^", "&", ¬
"*", "(", ")", "=", "+", "{", "}", "[", "]", "|", "\\", "/", "'", ",", "\""}
set astid to AppleScript's text item delimiters
repeat with this_replace_string in replace_strings
set fcbName to my FixName(fcbName, (contents of this_replace_string))
set clientCode to my FixName(clientCode, (contents of this_replace_string))
end repeat
set AppleScript's text item delimiters to astid
set fcbFolderPOSIX to POSIX path of (destination_ & fcbName) & "/"
do shell script ("mkdir -p " & fcbFolderPOSIX & clientCode & "/" & holdingfolder_names)
tell application "Finder" to update folder destination_
else
quit
end if
end run
on FixName(currentName, fixString)
set AppleScript’s text item delimiters to fixString
set listName to every text item of currentName
set AppleScript’s text item delimiters to “_”
return (listName as string)
end FixName