Reply To: Script to Automate Deletion of Specific Layers

#78734
Anonymous
Inactive

Here you are:

function removeLayers ( layersNamesArray ) {
var d, ls, l, n, r, c = 0;
if ( !app.documents.length
|| !layersNamesArray
||!(layersNamesArray instanceof Array) ) return;
d=app.activeDocument;
ls = d.layers;
n = ls.length;

r = new RegExp ( “^(“+layersNamesArray.join(“|”)+”)$”, “” );

while ( n– ) {
l = ls[n];
if ( r.test ( l.name ) && n>0 ) {
l.remove()
c++;
}
}

alert( c>0? “Removed “+c+” layers” : “Removed none layers” );
}
var arr = [“myName”,”yolo”];
var u;
app.doScript (“removeLayers(arr);”, u,u, UndoModes.ENTIRE_SCRIPT );

This article was last modified on October 13, 2015

Comments (0)

Loading comments...