Brad
i tried your code in a clean test app, and it worked just as I want it to
but now I’m having trouble introducing it into my files… and I’m struggling…
I’m posting my code in hopes that you might have some insight, as I’m sure that due to my inexperience, I’m overlooking something
here’s my app code:
on clicked theObject
if name of theObject = "Reset" then
tell window "Folder Generator"
set contents of text field "fcbName" to ""
set contents of text field "clientCode" to ""
end tell
else if name of theObject = "Generate" then
set whichServer to current row of matrix "ServerName" of window "Folder Generator"
if whichServer is equal to 1 then
--PrePress Server
set destination_ to (choose folder with prompt "Choose a destination for the job folder.") as string
set fcbFolderName to contents of text field "fcbName" of window "Folder Generator"
set prefix_ to text -5 thru end of fcbFolderName & "_"
set clientFolderCode to contents of text field "clientCode" of window "Folder Generator"
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 fcbFolderName to my FixName(fcbFolderName, (contents of this_replace_string))
set clientFolderCode to my FixName(clientFolderCode, (contents of this_replace_string))
end repeat
set AppleScript's text item delimiters to astid
set fcbFolderPOSIX to POSIX path of (destination_ & fcbFolderName) & "/"
do shell script ("mkdir -p " & fcbFolderPOSIX & clientFolderCode & "/" & holdingfolder_names)
tell application "Finder" to update folder destination_
else if whichServer is equal to 2 then
--AD Server
set destination_ to (choose folder with prompt "Choose a destination for the job folder.") as string
set fcbFolderName to contents of text field "fcbName" of window "Folder Generator"
set prefix_ to text -5 thru end of fcbFolderName & "_"
set subfolder_names to prefix_ & "{Old_QXD,ILL_EPS,PSD,Resources,EPS_TIF}"
set transmission_names to prefix_ & "Transmissions/{In,Out}"
set replace_strings to ¬
{" ", " ", "-", "_", "__", "~", "`", ":", ";", "!", "@", "â„¢", "'", "®", "#", "$", "?", "<", ">", "%", "^", "&", ¬
"*", "(", ")", "=", "+", "{", "}", "[", "]", "|", "\\", "/", "'", ",", "\""}
set astid to AppleScript's text item delimiters
repeat with this_replace_string in replace_strings
set fcbFolderName to my FixName(fcbFolderName, (contents of this_replace_string))
end repeat
set AppleScript's text item delimiters to astid
set fcbFolderPOSIX to POSIX path of (destination_ & fcbFolderName) & "/"
do shell script ("mkdir -p " & fcbFolderPOSIX & subfolder_names)
do shell script ("mkdir -p " & fcbFolderPOSIX & transmission_names)
tell application "Finder" to update folder destination_
end if
end if
end clicked
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