Goal
I would like to use AppleScript to open Automator and add specific actions to a new Workflow, regardless of the localization settings (language). In other words, I would like to use AppleScript to open a new Automator workflow and add specific actions in a specific order (at indexes) using the bundle identifiers of each action (to avoid language issues) or some other way to avoid language issues.
The Problem
The problem is that I cannot get Automator to add anything to the workflow.
- What is the syntax for the
addcommand? - Can I use bundle ids to add actions?
So far, this is what I have:
tell application "Automator"
make new workflow with properties {name:"Merge PDF Files"} -- Skips Opening Dialog
add "Get Specified Finder Items" to workflow 1 at index 1 --("com.apple.Automator.SpecifiedFiles")
add "PDF-Seiten kombinieren" to workflow 1 at index 2 --("com.apple.action.joinpdf")
end tell
Complete Code for a Merge PDF Files Droplet
After bwaldie posted his answer, I would like to share my useful droplet. You can put it on any Mac running OS X (especially useful for people who aren't familiar with Automator). To use it, just paste the code into the AppleScript Editor and save it as an application.
See code for droplet:
on open the_Droppings
-- CONVERT INPUT LIST OF ALIASES TO POSIX PATHS
repeat with itemStep from 1 to count of the_Droppings
set item itemStep of the_Droppings to POSIX path of item itemStep of the_Droppings
end repeat
tell application "Automator"
activate
set theWorkflowName to "Merge PDF Files"
set msg to "no"
tell application "Finder" to if exists POSIX path of ((path to temporary items as string) & theWorkflowName & ".workflow" as string) as POSIX file then set msg to "yes"
if msg is "no" then
set myWorkflow to make new workflow with properties {name:theWorkflowName, path:POSIX path of ((path to temporary items as string) & theWorkflowName & ".workflow" as string)}
add (first Automator action where its id = "com.apple.Automator.SpecifiedFiles") to myWorkflow at index 1
add (first Automator action where its id = "com.apple.action.joinpdf") to myWorkflow at index 2 --("com.apple.Automator.SpecifiedFiles")
else
set myWorkflow to open POSIX path of ((path to temporary items as string) & theWorkflowName & ".workflow" as string)
end if
set actionsList to name of Automator action of myWorkflow
set firstAction to item 1 of actionsList
tell myWorkflow
set value of setting of Automator action firstAction to the_Droppings -- MUST BE LIST OF POSIX PATHS
end tell
end tell
end open