FORUMS: list search recent posts

Rename text layer name based on the text content.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Sumesh Surendran
Rename text layer name based on the text content.
on Feb 11, 2020 at 11:43:07 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?


Return to posts index

Andrei Popa
Re: Rename text layer name based on the text content.
on Feb 11, 2020 at 4:13:08 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.


Return to posts index

Sumesh Surendran
Re: Rename text layer name based on the text content.
on Feb 12, 2020 at 1:10:38 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


Return to posts index


Andrei Popa
Re: Rename text layer name based on the text content.
on Feb 12, 2020 at 1:17:04 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.


Return to posts index

Sumesh Surendran
Re: Rename text layer name based on the text content.
on Feb 12, 2020 at 1:30:06 pm

unable to execute script at line 5. expected: )


Return to posts index

Andrei Popa
Re: Rename text layer name based on the text content.
on Feb 12, 2020 at 1:33:39 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.


Return to posts index


Sumesh Surendran
Re: Rename text layer name based on the text content.
on Feb 12, 2020 at 1:57:53 pm

Now it works perfectly, Thank you very much Andrei :-)


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]