Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Source text automatically name layer based on stacking

  • Source text automatically name layer based on stacking

    Posted by John Burgess on July 3, 2021 at 6:00 pm


    I have several hundred layers I want to pick whip the source text to via a main control comp.The layers in the control comp are named sequentially ‘layer_01, layer_02, layer_03″ etc

    comp(“Text Controller”).layer(“layer_01”).text.sourceText

    Is there a way to apply a single expression to all layers that will reference the one above and add a +1 to the layer name rather than manually having to change or pick whip each layer.

    Many thanks.

    John Burgess replied 3 years ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    July 3, 2021 at 6:11 pm

    You could try this (set startIndex to the index of the first (lowest numbered) layer participating):

    startIndex = 1;

    comp("Text Controller").layer("layer_" + (index-startIndex+1).toString().padStart(2,'0')).text.sourceText;

  • John Burgess

    July 3, 2021 at 6:31 pm

    Thanks so much for your reply Dan, i’m getting the below warning. Any ideas?

    I also forgot to mention the source text has been added via Essential Properties, is that likely to make a difference.

  • Dan Ebberts

    July 3, 2021 at 8:32 pm

    I guess either you have an old version of AE, or you have File>Project Settings>Expressions set to Legacy ExtendScript. In either case, this should fix it:

    startIndex = 1;

    idx = index-startIndex+1;

    str = (idx < 10 ? "0" : "") + idx;

    comp("Text Controller").layer("layer_" + str).text.sourceText;

  • John Burgess

    July 3, 2021 at 9:01 pm

    Thank you Dan this worked perfectly

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy