Skip to main content
Participant
December 15, 2015
Question

Is there a way to batch a group of files with a "layer comps to files" script...?

  • December 15, 2015
  • 1 reply
  • 214 views

Accessing a script through batch in Photoshop ;

Is there a way to batch a group of files with a "layer comps to files" script where the end result will include the original's file name with the layer comp's name?

example;

Original file name = 12345_T1_Master_2016.psd

Layer comps included in that file = Yellow, Red, Blue

End result required = 12345_T1_Master_2016_Yellow.psd, 12345_T1_Master_2016_Red.psd, 12345_T1_Master_2016_Blue.psd

Thank you! Anyone that has the answer to this batching/ scripting issue!

Wes

This topic has been closed for replies.

1 reply

natrev
Legend
December 16, 2015

Hi,

Try this Code...

#target photoshop

app.bringToFront();

var docRef = app.activeDocument;

var docName=docRef.name.replace(/\.[^\.]+$/, '');

var docPath = app.activeDocument.path;

var n= docRef.layerComps.length

for(i=0;i<n;i++){

    var FileName=docName+"_"+docRef.layerComps.name+".psd"

    docRef.layerComps.apply();

    OutFoldPSD(docPath+"/FinalFiles",FileName);

    }

function OutFoldPSD(dnme,dn){//PSD

    var outfolder = new Folder(dnme)

    if (outfolder.exists == false){

         outfolder.create();

         var saveFile = new File(outfolder + "/" + dn);

        SavePSD(saveFile);}

    else{

        var saveFile = new File(outfolder + "/" + dn);

        SavePSD(saveFile);}

}

function SavePSD(saveFile){

    psdSaveOptions = new PhotoshopSaveOptions();

    psdSaveOptions.embedColorProfile = true;

    psdSaveOptions.alphaChannels = true; 

    activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.UPPERCASE);

}

- yajiv