ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

having a script find a substring in a layer name

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Dirk de Jong
having a script find a substring in a layer name
on Feb 21, 2018 at 5:57:28 pm

I have a script that creates several layers in the comp when run - and now I'm trying to build a "remover" script that allows for convenient one click removal of those layers when desired.

When the first script creates the layers it names them something descriptive indicating what the layer does (that part is the same every time the "creator" script runs) and then it appends current date and time to the name to make them unique within the project. So (assuming the layer names haven't been edited in the meantime) my "remover" script can know what the descriptive part of the name is (but not the other date/time part of the layer name) So I have my "remover" script looping through the comp layers trying to identify these layers by part of the name.

I find that
layerName=="nova"
works fine to find a layer that is precisely named "nova" but when I try layerName.includes("nova") or layerName.startsWith("nova") I'm getting undefined errors...

what's a good way to do this in an AE script ? Thanks for any suggestions.


Return to posts index

Dirk de Jong
Re: having a script find a substring in a layer name
on Feb 21, 2018 at 6:20:40 pm

[Dirk de Jong] "what's a good way to do this in an AE script ?"

since creating the original post I've found that it seems like I can use layerName.indexOf("nova") to get the info I need


Return to posts index

Dan Ebberts
Re: having a script find a substring in a layer name
on Feb 21, 2018 at 7:09:09 pm

It sounds like you're on the right track. One thing I do when my script may later need to remove layers it has created, is to put the identifying info in the layer's comment field, which is much less likely to be edited by someone.

Dan



Return to posts index


Dirk de Jong
Re: having a script find a substring in a layer name
on Feb 21, 2018 at 7:37:50 pm

[Dan Ebberts] "put the identifying info in the layer's comment field"

That's a great idea - and at first I was thinking it might only apply to items (like solids or comps) individually represented in the project window (which is the only place I've ever noticed comments) but I just tried it with a text layer in my comp and it seemed to work there too (so I'm hopeful it will work for camera and light layers too) - although I'm not sure how I would ever view a comment on a text layer through the AE UI...

Thanks for the tip.


Return to posts index

Dan Ebberts
Re: having a script find a substring in a layer name
on Feb 21, 2018 at 7:41:20 pm

Layer comments have their own column in the Timeline panel if you want to display them.


Dan



Return to posts index

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