Copy link to clipboard
Copied
Hi,
How can I remove all form layers in an entire project by name.
I understand that this should be a script.
I used ".remove ()", but unfortunately this isn't really a problem I know much about.
Please help)
app.activeDocument.layers.getByName('123').Remove();
Copy link to clipboard
Copied
Huh? What does this have to do with After Effects? Your syntax is completely wrong to begin with and would only be relevant for PS or AI.
Mylenium
Copy link to clipboard
Copied
You have to loop through all the items in the project bin, looking for comps, then loop backwards through each comp looking for layers named "123" and remove them:
var myComp;
for (var i = 1; i <= app.project.numItems; i++){
if (app.project.item(i) instanceof CompItem){
myComp = app.project.item(i);
for (var j = myComp.numLayers; j > 0; j--){
if (myComp.layer(j).name == "123"){
myComp.layer(j).remove();
}
}
}
}
Copy link to clipboard
Copied
If you want to delete only the ShapeLayers, you have to add an extra check to Dan's snippet:
var myComp;
for (var i = 1; i <= app.project.numItems; i++){
if (app.project.item(i) instanceof CompItem){
myComp = app.project.item(i);
for (var j = myComp.numLayers; j > 0; j--){
if (myComp.layer(j).name == "123" &&
myComp.layer(j) instanceof ShapeLayer){
myComp.layer(j).remove();
}
}
}
}
Copy link to clipboard
Copied
exactly what is needed. You are God of JS)
Thank you so much!
Copy link to clipboard
Copied
wow, it is Great! Thank you very very much)