Highlighted

remove() ShapeLayers by name

Community Beginner ,
Apr 11, 2020

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();

Topics

Scripting

Views

339

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

remove() ShapeLayers by name

Community Beginner ,
Apr 11, 2020

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();

Topics

Scripting

Views

340

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Apr 12, 2020

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Guide ,
Apr 12, 2020

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();
			}
		}
	}
}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Apr 12, 2020

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();
			}
		}
	}
}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Apr 13, 2020

Copy link to clipboard

Copied

andreip14565073,

exactly what is needed. You are God of JS)
Thank you so much!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Apr 13, 2020

Copy link to clipboard

Copied

wow, it is Great! Thank you very very much)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...