Forums › Adobe After Effects Expressions › Find selected Layers with part of name.
-
Find selected Layers with part of name.
-
Fabian Brugger
February 6, 2023 at 10:29 amIs it possible to get to all selected layers that have, for example, the name scale in its name.
So the layer would be called something like: Frame1_Icon1_Scale
And i want to find all layers with the ending Scale or with Scale in its name anywhere (whatever is possible) to animate it through a script.
I write this but it just finds the exact name:
var comp = app.project.activeItem;
var layers = comp.selectedLayers;
for (var i = 0; i < layers.length; i++) {
if (layers[i].name = “scale”) {
var scalelayerkeys = layers[i].property(“Transform”).property(“Scale”)
scalelayerkeys.setValueAtTime(0,[0,0]);
scalelayerkeys.setValueAtTime(0.4,[110,110]);
scalelayerkeys.setValueAtTime(0.7,[100,100]);
}
}
-
Filip Vandueren
February 6, 2023 at 1:28 pmtry:
if (layers[i].name.indexOf("scale")>-1) {
or for case insensitive matching:
if (layers[i].name.match(/scale/gi)!==null) {
-
Fabian Brugger
February 6, 2023 at 1:45 pmThe .indexOf version does exactly what i want.
But will use the one with case insensitive matching so it has less possibilities for errors
Thank you!
Log in to reply.