Copy link to clipboard
Copied
Hello all!
Does anyone know if it is possible to batch process an action on each layer within a single document?
I have no real ability to script myself so I've been hunting around for any clue if this has ever been done before and haven't found any promising leads.
Basically, say if I have an action that processes the active layer, how could I get photoshop to loop the action through each layer from top down until reaching the last layer at the bottom?
Thanks for any insight on this!
Copy link to clipboard
Copied
A Script could perform tasks itself or run an Action on each Layer, but the Layer naturally needs to be eligible for the operations (an Adjustment Layer without Layer Mask for example can not be filtered).
What does the Action encompass?
Copy link to clipboard
Copied
Hi Danykweb,
Try this Code...
var docRef=app.activeDocument;
var n = docRef.layers;
for (i=0; i<n.length; i++) {
var theLayer = n;
if (theLayer.typename == "ArtLayer") {
docRef.activeLayer=theLayer;
if(docRef.activeLayer!=docRef.backgroundLayer){
app.doAction ('Crop','Dummy');// Action Name and Action Set Name like Screen shot
}
}
}
-yajiv
Copy link to clipboard
Copied
hi i also want the same but how to use the for loop function to hide the previous layer after the action ran.
so basically in the active layer the action need to run and switch back the next layer by turning visibility off for the previous layer.
Copy link to clipboard
Copied
Hi Venkat,
Try this code:
var docRef=app.activeDocument;
var n = docRef.layers;
for (i=0; i<n.length; i++) {
turnOFF(docRef,n.length);
var theLayer = n;
if (theLayer.typename == "ArtLayer") {
docRef.activeLayer=theLayer;
if(docRef.activeLayer!=docRef.backgroundLayer){
app.doAction ('Crop','Dummy');// Action Name and Action Set Name like Screen shot
theLayer.visible=false; //
}
}
}
function turnOFF(docRef,len){
for (j=0; j<len; j++) {
docRef.layers
.visible=false; }
}