I am trying to simplify some applescripts that I have been using as folder action scripts by using AppleScript studio to combine some of the functions. My primary reason is that the standard Applescript does not allow more than three buttons and I know have need for more than three. I am having difficulty getting each of the three selectable buttons to supply me with a value that I can use to name a folder. I will supply my original script to see if there are any ideas. As I am not scripting year 'round, I tend to lose skills in the off season. Any help would be appreciated.
on adding folder items to this_folder
tell application "Finder"
display dialog "What is This File's P Ship Date?" default answer "MM-DD-YY" buttons {"Cancel", "OK"} default button 2
set the P_Ship_Date to the text returned of the result
delay 1
display dialog "Which plant is this order going to?" buttons {"TN", "NH", "LA"} default button 1
set the Plant_Location to the button returned of the result
end tell
try
tell application "Finder"
make new folder at folder Plant_Location of folder "To Be Printed" of folder "Cover Drawings" of folder "Cover Logix" of disk "Scale Drawings" with properties {name:P_Ship_Date}
end tell
tell application "Finder"
(*be sure to change the short user name to match your user's short user name*)
duplicate files of folder "To Be Printed" of folder "Desktop" of folder "vynall" of folder "Users" of startup disk to folder P_Ship_Date of folder Plant_Location of folder "To Be Printed" of folder "Cover Drawings" of folder "Cover Logix" of disk "Scale Drawings" with replacing
end tell
on error
tell application "Finder"
duplicate files of folder "To Be Printed" of folder "Desktop" of folder "vynall" of folder "Users" of startup disk to folder P_Ship_Date of folder Plant_Location of folder "To Be Printed" of folder "Cover Drawings" of folder "Cover Logix" of disk "Scale Drawings" with replacing
end tell
end try
tell application "Finder"
--make new Finder window to folder "To Be Printed" of folder "Cover Drawings" of folder "Cover Logix" of disk "Scale Drawings"
end tell
tell application "Finder"
delete files of folder "To Be Printed" of folder "Desktop" of folder "vynall" of folder "Users" of startup disk
--delay 2
--close window "To Be Printed"
end tell
activate application "VectorWorks"
end adding folder items to
(*Script Written and compiled by Brian Eibert, 10/11/06, REVISED 7/28/09 BK EIBERT, revised 8/6/09, BK Eibert, v2.2 10/21/09 BK Eibert, v2.3 10/28/09, commented out need for opening windows to view files, BK Eibert*)
I did some more digging and came up with a bit of a solution. I haven’t completed the process, but this has helped me along a bit:
on clicked theObject
tell window "Cover Drawing Director"
set the P_Ship_Date to contents of text field "P Ship Date"
if name of theObject is "Tennessee" then
set the Plant_Location to "TN"
else
if name of theObject is "Louisiana" then
set the Plant_Location to "LA"
else
set the Plant_Location to "NH"
end if
end if
display dialog "The P Ship date is " & P_Ship_Date & return & "The Plant location is " & Plant_Location
(*end tell
try
tell application "Finder"
make new folder at folder Plant_Location of folder "To Be Printed" of folder "Cover Drawings" of folder "Cover Logix" of disk "Scale Drawings" with properties {name:P_Ship_Date}
end tell
tell application "Finder"
(*be sure to change the short user name to match your user's short user name*)
duplicate files of folder "To Be Printed" of folder "Desktop" of folder "beibert" of folder "Users" of startup disk to folder P_Ship_Date of folder Plant_Location of folder "To Be Printed" of folder "Cover Drawings" of folder "Cover Logix" of disk "Scale Drawings" with replacing
end tell
on error
tell application "Finder"
duplicate files of folder "To Be Printed" of folder "Desktop" of folder "beibert" of folder "Users" of startup disk to folder P_Ship_Date of folder Plant_Location of folder "To Be Printed" of folder "Cover Drawings" of folder "Cover Logix" of disk "Scale Drawings" with replacing
end tell
end try
tell application "Finder"
delete files of folder "To Be Printed" of folder "Desktop" of folder "beibert" of folder "Users" of startup disk*)
end tell
--activate application "VectorWorks"
end clicked
I just had to figure out how to get the name of the button selected. I feel foolish, but you never learn if you don’t make mistakes.
be careful with tell blocks. Tell blocks should only be used for lines which include the appropriate references.
You can distinguish buttons for example with this syntax
on clicked theObject
set buttonName to (get name of theObject)
set the P_Ship_Date to string value of text field "P Ship Date" of window "Cover Drawing Director"
if buttonName is "Tennessee" then
set the Plant_Location to "TN"
else if buttonName is "Louisiana" then
set the Plant_Location to "LA"
else
set the Plant_Location to "NH"
end if
display dialog "The P Ship date is " & P_Ship_Date & return & "The Plant location is " & Plant_Location
.