Skip navigation
Simon Batchelor
Currently Being Moderated

Mix & match export layers to files action

Aug 2, 2012 9:01 AM

Hi Folks

Newby poster here hoping you can help.


I have a file with 181 layers and need to export 180 individual layers with 1 other layer switched on (so 2 layers on in each export). Any ideas how to do this with an action or script?



  • Currently Being Moderated
    Aug 2, 2012 9:54 AM   in reply to Simon Batchelor

    Hi Simon

    You can use Layer comps to do this, but the down side is that you have to toggle the layer visibility for every layer combination.


    Open up the Layer comps panel in Window> Layer Comps


    Turn on the visibility for the two layers that you need to save out for that single export. Then click New Layer Comp in the layer comps panel. Do so for all the combinations. When you have all the comps, go to File>Scripts>Layer comps to files. Then photoshop will save out all the comps for you.


    Use keyboard shortcuts to increase your speed.




    For more info: 41001031ab64-7870a.html g-layer-comps-to-create-variations

    Mark as:
  • Currently Being Moderated
    Aug 2, 2012 10:54 PM   in reply to Simon Batchelor

    Several of the regulars from

    also drop by here, but for assistance with a Scripting approach to the issue you might want to ask over there, too.

    But please be more specific – which export exactly (format etc.) and how are the layers structured (a screenshot of the Layers Panel might help).

    Mark as:
  • Currently Being Moderated
    Aug 3, 2012 1:25 AM   in reply to Simon Batchelor

    Could you give this a try?

    // combine top level layers with last one and save jpgs;
    // be advised: this  overwrites existing jpgs of the same name without prompting. 
    // 2012, use it at your own risk;
    #target photoshop;
    if (app.documents.length > 0) {
    var thedoc = app.activeDocument;
    // getting the name and location;
    var docName =;
    if (docName.indexOf(".") != -1) {var basename = docName.match(/(.*)\.[^\.]+$/)[1]}
    else {var basename = docName};
    // getting the location, if unsaved save to desktop;
    try {var docPath = thedoc.path}
    catch (e) {var docPath = "~/Desktop"};
    // jpg options;
    var jpegOptions = new JPEGSaveOptions();
    jpegOptions.quality = 9;
    jpegOptions.embedColorProfile = true;
    jpegOptions.matte = MatteType.NONE;
    // hide all but last layer;
    thedoc.layers[thedoc.layers.length - 1].visible = true;
    for (var m = 0; m < thedoc.layers.length - 1; m++) {thedoc.layers[m].visible = false};
    for (var n = 0; n < thedoc.layers.length - 1; n++) {
    var theLayer = thedoc.layers[n];
    theLayer.visible = true;
    //save jpg as a copy:
    thedoc.saveAs((new File(docPath+"/"+basename+"_"+n+".jpg")),jpegOptions,true);
    theLayer.visible = false;
    //that’s it; thanks to xbytor;
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points