• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Batch process action on each layer in a document

New Here ,
Feb 23, 2016 Feb 23, 2016

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!

TOPICS
Actions and scripting

Views

590

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
community guidelines
Adobe
Community Expert ,
Feb 23, 2016 Feb 23, 2016

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?

Votes

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
community guidelines
Engaged ,
Feb 23, 2016 Feb 23, 2016

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

        }

    }

Screen Shot 2016-02-23 at 4.32.37 pm.png

-yajiv

Votes

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
community guidelines
Explorer ,
Oct 23, 2016 Oct 23, 2016

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.

Votes

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
community guidelines
Engaged ,
Oct 26, 2016 Oct 26, 2016

Copy link to clipboard

Copied

LATEST

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;

        }

    }

Votes

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
community guidelines