O.rka
O.rka

Reputation: 30677

How to loop an Automator workflow?

enter image description here

So the steps are:

  1. Run Applescript
  2. Ask for Finder Items
  3. Run Shell Script
  4. Ask for Finder Items
  5. Run Shell Script
  6. Ask for Text
  7. Run Shell Script

1 is a dialogue box, 2 and 4 specify a folder and file, respectively. Once those are specified, I would like to use 6 and 7 repeatedly because 7 is dependent on the entry of 6. Is there anyway to make a loop where it finishes 7 and then goes back to 6 unless specified to stop?

Upvotes: 1

Views: 2097

Answers (1)

Digital Trauma
Digital Trauma

Reputation: 15986

I think you could put steps 1-5 in workflow A, then put a final "Run Workflow" step in workflow A. Then you could set up another workflow, B to run steps 6-7, followed by a "Loop" action, which will continue to run steps 6-7 continuously.

However if this was me, I think I'd put the whole thing in an Applescript (embedded in a workflow if necessary). I don't know the details of your steps, but the skeleton of the applescript would be something like this:

-- Step 1: Run Applescript
(*
Insert whatever Applescript statements you require here
*)

-- Step 2: Ask for Finder Items
-- https://developer.apple.com/library/mac/documentation/applescript/conceptual/applescriptlangguide/reference/aslr_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW4
set fileListA to choose file with multiple selections allowed

-- Step 3: Run Shell Script
set output to do shell script "echo 123"

-- Step 4: Ask for Finder Items
set fileListB to choose file with multiple selections allowed

-- Step 5: Run Shell Script
set output to do shell script "echo abc"

repeat
    -- Step 6: Ask for Text
    -- https://developer.apple.com/library/mac/documentation/applescript/conceptual/applescriptlangguide/reference/aslr_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW12
    set dialogResult to display dialog "Enter text" default answer ""

    -- Step 7: Run Shell Script
    set output to do shell script "echo XYZ"
end repeat

Upvotes: 1

Related Questions