0

I'm trying to use Automator to create a "Quick Action" that will archive and encrypt a folder. I create a workflow that looks like this:

[create archive]
[ask for text]    - for password
[shell script]    - will run openssl command to encrypt the zip archive

The shell script gets the output of the previous step as an argument. But I need the output of both the previous steps. Is there a way to do that? The create archive step gives me a path to the zip file, and the ask for text gives me the password text.

1 Answer 1

1

In an Automator workflow, each action gets its input from the previous action, does its thing, and returns its results for the next action to use. Any given action can add, change, or remove its input items, so if you want to keep something for a later action, you can use variables to store the desired items/results.

The following example uses Ask for Finder Items to get a path, but since Ask for Text uses its input for the dialog, a Set Value of Variable is used to save the path, where later it is added back into the workflow items. A Run Shell Script action can then get all these items and arrange them based on their order:

Automator workflow

2
  • It works, but I'm not sure why. I guess the "Get Value of Variable" action passes through its input, so it passes two outputs to "Run Shell Script" – both the variable path and the text output (password) from the previous step?
    – Rob N
    Jan 14 at 15:26
  • 1
    If you look at an action’s results, notice that it is a list. Ask for Text takes text as an input and returns text, so the result will be a list of 1 item. Get Value of Variable takes anything as an input and returns that and the variable contents, so the result is now a list of 2 items. Run Shell Script is then passing its input list as arguments to the shell script, so the items can be referenced by index.
    – red_menace
    Jan 14 at 17:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .