Looping a whole automation

Ok I have this big automation, which works perfectly, but I’ve used a “user prompt” at the beginning in order to decide which value was chosen to go through all the automation.
But now I have to use that multiple times. and it can be a bit long, so I’d like to know if I can prepare some kind of list of “values” and run the automation so that it runs for all the different values at once.


Hi @Yves ,
I didn’t understand what you are asking exactly but I will try to answer,

you can create a collection variable, a collection stores multiple values of the same type (Layer/Item/Number/Text and more) as a list, you first need to add values items to the collection and then you can loop through the items in the collection and repeat the same actions on all the values in the collection like you do with a simple loop.

I created an example for an automation the that creates a collection of all the words in a text variable and then loop through the items and create text layer for every item in the collection, so basically this automation creates a text layer for every word in a sentence.

Download -
Collection Example.json (7.5 KB)

the process of adding items to a collection is quite simple, there is an action for adding one item to the collection and in some cases there are multiple actions that can add many items automatically…

for example in this case I used the collection action “add words as elements”, this action split the text based on the empty spaces between the characters and adds each word to the collection, I could also use the “add element” action and manually add each item to the collection separately.

looping through the items is a bit unintuitive, most loops gives you automatically each layer as the value of the loop, so if you loop over the “layers in the active comp”, “loop1” will represent each layer.
looping on a collection won’t work like this, you will have to set up the loop yourself, but it’s not that complicated(3 lines), you need to use the loop “custom amount of times” option and use the “collection length” property of the collection, this will set the number of times the loop will run to the number if elements in the collection so if the collection contain 4 elements the loop will run 4 times (but the value of the loop will be the number of the cycle 1,2,3,4 so “loop1” won’t represent a collection element, it will represent just an index - number),

then you needs to add 2 more lines within the loop to set the index of the collection, the index will determine the current item you want to look at, the index won’t be changed automatically based on the loop index, so if you won’t set it to the loop index it will stay on the first item and run the loop multiple times with the first item in the collection.
then you will need to create a variable for the item itself to access it’s properties and actions, so after you set the index of the collection you needs to set a variable with the collection property “element at index”, it will give you the current item at this index.

that’s a long explanation for just 3 automation lines but hope it answered your question,
please let me know if I didn’t answer your question at all… or you just have more questions.


Hi @alonshemer
And thanks again, sorry I wasn’t perfectly clear with my request but you actually gave me exactly what I was expected. Now my script runs in one go and that’s great. I hadn’t understood the concept of the “collection” but now I get it, and that’s what I needed!

All the best