Search code examples
applescriptautomator

Automator: I want to ask for list of options and then run a specific workflow based on the choice I make


I've cobbled together an After Effects render farm which outputs image sequences. I have a series of Automator workflows (which are currently run as apps) that convert these frames into video using FFMPEG.

It works great, but I need over half a dozen different workflows – one for each major framerate (24fps, 25fps, 30fps, etc, and a duplicate of each of those that creates video with audio if the original source folder contains an audio file.

I'm fine with having so many workflows, but I'd like to consolidate my exported apps into one master Automator app that simply asks what frame rate I want (from a list) and then takes that choice and runs the specific workflow (or app) associated with that choice.

At the minute, I've adapted a 'Run AppleSript' action which I found on on Stack Overflow. I'm starting small and testing it with a few frame rates…

on run {input, parameters}

    choose from list {"ProRes 24", "ProRes 24 with Audio", "ProRes 30", "ProRes 30 with Audio"} with prompt "Please make your selection" without multiple selections allowed and empty selection allowed
    return the result as string

    return input
end run

It 'works', in terms of it asking me the correct questions, but I'm not really sure where I go from here. I think I need to pass the answer into a variable and use that to make a selection in the Run Workflow action (or Launch Application, seeing as how my workflows are also apps?), but I don't know how.

Any help would be appreciated.


Solution

  • If each of the list items are the actual names of the apps, then all you need after the choose from list command is:

    if not result is equal to false then activate application (result as string)
    

    This will open the selected app.

    It also doesn't need to be an Automator app, it could be an AppleScript app that has just these two commands:

    choose from list {"ProRes 24", "ProRes 24 with Audio", "ProRes 30", "ProRes 30 with Audio"} with prompt "Please make your selection" without multiple selections allowed and empty selection allowed
    if not result is equal to false then activate application (result as string)