Q: AppleScript no longer works after upgrading from Mountain Lion to Yosemite
Hey all,
I have an AppleScript I use for my business that automates a process I use daily. This script does the following automatically:
- Creates a Job Folder inside a Client Folder
- Job folder created is based on the date with an optional description
- Creates subfolder inside the Job Folder for client original files, formatted files, final files, etc.
- Highlights the Client folder in the label color red
- Highlights the new Job folder also in the label color red
- Sets a Reminder that this new job is in my ToDo List
This script is fantastic and works like a charm in Mountain Lion.
However, I upgraded a testing system to Yosemite, and my script fails.
I get the following error message:
"The variable thePath is not defined"
I'm stuck, and don't know what has changed from Mountain Lion to Yosemite that would cause this error.
I would really appreciate it if someone could review this script and perhaps let me know how to correct this error.
Here is my script:
on run {input, parameters}
set thePath to the first item of the input -- just one
tell (current date)
set textMonth to text -2 thru -1 of ("0" & (it's month as integer)) -- leading zero
set textYear to text -2 through -1 of (it's year as text)
end tell
set jobName to text returned of (display dialog "Please enter the three letter company code:" default answer "Three Letter Job Code")
set jobNum to text returned of (display dialog "Please enter Job Number/Date:" default answer {textMonth & textYear & "01"})
set jobLang to text returned of (display dialog "Please enter Project & Description:" default answer "SCH Card 1 PDF")
set jobNumName to jobName & jobNum & " - " & jobLang
try
makeFolderStructure out of {jobNumName, {"Client Originals"}, {"Fax"}, {" FORMATTED FILES"}, {" FINAL DELIVERABLES"}, {" TRANSLATION FILE"}} at thePath
on error errorMessage number errorNumber -- oops
activate me
display alert "Error " & errorNumber message errorMessage
end try
tell application "Finder"
# parent folder
set the label index of thePath to 2 -- 2 = red
set the folder_name to the name of thePath
# child folder
get ((thePath as text) & jobNumName) as alias
set the label index of the result to 2 -- 2 = red
end tell
-- Adds an item in the iCal ToDo list for this job
set summarycal to folder_name & " - " & jobLang
tell application "Reminders"
set theList to list "Send to Translators"
set newToDo to make new reminder with properties {name:summarycal, container:theList}
end tell
return thePath
end run
to makeFolderStructure out of someItem at someFolder
(*
make the folder structure defined in someItem at someFolder
someList defines the structure:
nested list items create folders in the previous text item - {"A", {"B", {"C"}}} = /A/B/C
empty text items will create untitled folders
parameters - someItem [mixed]: the folder structure
someFolder [alias]: the destination folder
returns nothing
*)
set parentFolder to someFolder
if class of someItem is list then
repeat with anItem in someItem
if class of anItem is list then -- add subfolder(s)
makeFolderStructure out of anItem at someFolder
else -- add a new child folder at the current parent
tell application "Finder" to make new folder at parentFolder with properties {name:anItem}
set someFolder to the result as alias
end if
end repeat
else
tell application "Finder" to make new folder at someFolder with properties {name:someItem}
end if
end makeFolderStructure
Once again, any help would be GREATLY appreciated! I'm completely stuck.
Mac Pro, OS X Yosemite (10.10.5), null
Posted on May 26, 2016 11:14 PM
You can give Automator (or your Automator application) Accessibility permissions in the System Preferences > Security & Privacy > Privacy tab, but it also looks like the Reminder part of your script should be something like:
tell application "Reminders" tell list "Send to Translators" tell (make new reminder) to set its name to summarycal end tell end tell
Posted on May 31, 2016 11:59 AM