Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Rename text layer name based on the text content.

  • Rename text layer name based on the text content.

    Posted by Sumesh Surendran on February 11, 2020 at 11:43 am

    Hi,

    I want to rename text layer name based on the text content.

    for example, I have text 1 layer which says Sunday, text 2 layer which says Monday, text 3 layer which says Tuesday……so on

    how to rename?
    text 1 layer to Sunday
    text 2 layer to Monday
    text 3 layer to Tuesday

    like this I have 100 or more layers

    is there way to do it fast with expression or scripts?

    Sumesh Surendran replied 6 years, 3 months ago 2 Members · 6 Replies
  • 6 Replies
  • Andrei Popa

    February 11, 2020 at 4:13 pm

    Script:

    crtComp = app.project.activeItem;

    for (var i=1;i<=crtComp.numLayers;i++){
    crtComp.layer(i).name = crtComp.layer(i).text.sourceText.value;
    }

    Andrei
    My Envato portfolio.

  • Sumesh Surendran

    February 12, 2020 at 1:10 pm

    Thank you Andrei Popa, This is exactly I want.

    I think loop is breaking when there is another type of layer objects such as solid or shapes layer in between the text layers

    example:
    text layer 1 > renamed
    text layer 2 > renamed
    text layer 3 > renamed
    solid layer
    text layer 4 > did not renamed
    text layer 5 > did not renamed

  • Andrei Popa

    February 12, 2020 at 1:17 pm

    Try this:

    crtComp = app.project.activeItem;

    for (var i=1;i<=crtComp.numLayers;i++){
    currentLayer = crtComp.layer(i);
    if(currentLayer typeof TextLayer){
    currentLayer.name = currentLayer.text.sourceText.value;
    }
    }

    Andrei
    My Envato portfolio.

  • Sumesh Surendran

    February 12, 2020 at 1:30 pm

    unable to execute script at line 5. expected: )

  • Andrei Popa

    February 12, 2020 at 1:33 pm

    Sorry. I corrected this but then pasted the code from the clipboard. That one was not corrected ????

    crtComp = app.project.activeItem;

    for (var i=1;i<=crtComp.numLayers;i++){
    currentLayer = crtComp.layer(i);
    if(currentLayer instanceof TextLayer){
    crtComp.layer(i).name = crtComp.layer(i).text.sourceText.value;
    }
    }

    Andrei
    My Envato portfolio.

  • Sumesh Surendran

    February 12, 2020 at 1:57 pm

    Now it works perfectly, Thank you very much Andrei 🙂

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