Skip to main content
March 23, 2012
Question

searching through layer names for a specific word

  • March 23, 2012
  • 2 replies
  • 668 views

i need to find a way of finding a specific layer within each comp. The problem is the end of the layers name is different in each comp, so i want to match the start of the layer name.

eg.   'OliveOCC_33456.iff'

the "OliveOCC" part is always the same, so i need finding a way of only matching that part of the layer title in each comp.

does anyone have any ideas,

pleease helpy,

thanks, Sam

This topic has been closed for replies.

2 replies

Dan Ebberts
Braniac
March 23, 2012

I haven't tested this, but it will be something like this:

var myComp = (your comp);

var theName = 'OliveOCC';

var myLayer = null;

for (var i = 1; i <= myComp.numLayers; i++){

  if myComp.layer(i).name.substr(0,theName.length) == theName){

    myLayer = myComp.layer(i);

    break;

  }

}

Dan

Inspiring
March 23, 2012

Hey Sam,

do a search on  regular expressions, particularly how they are used in javascript.  This sort of thing is trivial with a regular expression.

Mike Cardeiro