Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions having a script find a substring in a layer name

  • having a script find a substring in a layer name

    Posted by Dirk De jong on February 21, 2018 at 5:57 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.

    Dan Ebberts replied 8 years, 3 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dirk De jong

    February 21, 2018 at 6:20 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

  • Dan Ebberts

    February 21, 2018 at 7: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

  • Dirk De jong

    February 21, 2018 at 7:37 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.

  • Dan Ebberts

    February 21, 2018 at 7:41 pm

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

    Dan

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