ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Renaming layers as part of a script

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Sebastian Törngren
Renaming layers as part of a script
on Mar 6, 2017 at 11:00:29 am
Last Edited By Sebastian Törngren on Mar 6, 2017 at 3:31:06 pm

Hi! I am currently working on a rather large script(for me atleast) to add a couple of effects to a source clip. One of those effects requires me to duplicate the layer 3 times, and I wish to rename those layers as well.

I have tried this code but .name does not seem to work for me:
var footage = app.project.activeItem.layer("Footage");

//RBG Split
var channels = ["red", "blue","green"];
var myLayer = footage;
var myName = myLayer.name;
var newLayer;

for (var i = 0; i < channels.length; i++){
newLayer = myLayer.duplicate()
newLayer.name = myName.substr(0,myLayer.length-3) + channels[i];
}

the script goes through just fine, creates 3 duplicates but does not rename anything.

Any suggestions to what could fix the issue?

EDIT: I just realized that you can swap between Source Name and Layer name in the Layer Editor. I've gotten it to work fine now.


Return to posts index

Walter Soyka
Re: Renaming layers as part of a script
on Mar 6, 2017 at 4:39:28 pm

This works. Make sure you're looking at layer names, not source names, in the timeline. Click the the Layer name / Source name column header in the timeline panel to toggle.

As an aside, "myName.substr(0,myLayer.length-3)" probably contains an error, as you're asking for the length of the myLayer layer object. Perhaps you mean for that to be myLayer.name.length-3?

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

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