Mobile app version of vmapp.org
Login or Join
Heady304

: Any way to export multiple layer comps to single psd in Photoshop? I'm trying to figure out how to export multiple layer comps to a single psd in Adobe photoshop cc. When I use the "layer

@Heady304

Posted in: #AdobePhotoshop #Export #LayerComposition

I'm trying to figure out how to export multiple layer comps to a single psd in Adobe photoshop cc. When I use the "layer comps to files" script it exports each layer comp to it's own psd.

Much thanks.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Heady304

2 Comments

Sorted by latest first Latest Oldest Best

 

@Jamie315

So... here's a script that should do what you want:

How to use the script: Select the layer comps you want to export and run the script. The rest of it is fairly self-explanatory.

Just save it as a .jsx file in the photoshop scripts folder and it should show up in the scripts list file > scripts > Selected Layer Comps to PSD...

Written for Photoshop CC, but it may work in older versions as well.



/*

Author: github.com/joonaspaakko Gist: gist.github.com/joonaspaakko/09e8e2a218038e15344d
<javascriptresource>
<name>Menu=Selected Layer Comps to PSD...</name>
<category>layercomps</category>
</javascriptresource>

*/

// enable double clicking from the Macintosh Finder or the Windows Explorer #target photoshop

try {

var save, cancel, dlg, tempkeep;

// If documents exist, do stuff...
if ( app.documents.length > 0 ) main();

function main() {

// Currently active document...
var doc = app.activeDocument;

// Document has been saved...
try {

var docPath = Folder( doc.fullName.parent ).fsName;
var docName = decodeURI( doc.fullName.name.substring( 0, app.activeDocument.fullName.name.indexOf(".") ) );

}
// Document has not been saved...
catch( e ) {

var docPath = "";
var docName = doc.name;

}

// THIS IS WHERE DECISIONS ARE MADE!?!?!?!?!?
dialog( doc, docName, docPath );

if ( !cancel ) {

// Duplicate current document
var tempDoc = doc.duplicate();

// Get layer comps
var layerComps = tempDoc.layerComps;

var shredder = [];

// Loop through each comp...
for ( i = 0; i < layerComps.length; i++ ) {

// Each looped comp
var comp = layerComps[ i ];

// If comp is not selected...
if ( !comp.selected ) {

// ...push it to shredder
shredder.push( comp );

}

}

// Loop through each shreddable comp...
for ( i = 0; i < shredder.length; i++ ) {

// Each looped comp
var comp = shredder[ i ];

// Shred it
comp.remove();

}

// Save temporary document as a psd file.
if ( save ) savePSD( doc, docName, docPath, tempDoc);

// Close temporary document.
tempDoc.close( SaveOptions.DONOTSAVECHANGES );

// If user checks the checkbox "Keep new file open",
// this part of the code actually opens up the file again...
if ( dlg.export.tempkeep.value ) {

// Find the file we just saved...
var savedFile = new File( dlg.destination.input.text + '/' + dlg.filename.input.text + '.psd' );

// ...open it
app.open( savedFile );

}

}
}
} catch ( e ) {}

function dialog( doc, docName, docPath, tempDoc ) {

// Prepare dialog...
var dialog = "dialog {
text: 'Export selected layer comps as PSD',
destination: Panel {
alignment: 'left',
alignChildren:['left','top'],
orientation: 'row',
text: 'File destination',
input: EditText { text: '"+ docPath +"/', preferredSize: [230,20] },
browse: Button { text: 'Browse...' },
},
filename: Panel {
alignment: 'left',
alignChildren:['left','top'],
orientation: 'row',
text: 'Filename',
input: EditText { text: '"+ docName +"', active: true, preferredSize: [320,20] },
},
export: Group {
alignment: 'right',
orientation: 'row',
tempkeep: Checkbox { text: 'Keep new file open', value: false },
save: Button { text: 'Save', properties:{ name: 'ok' } },
cancel: Button { text: 'Cancel' },
}
}";

// Make dialog
dlg = new Window( dialog );

// Browse click event...
dlg.destination.browse.onClick = function() {

// Browse for destination
destination = Folder.selectDialog("Select destination", docPath );

// If destination was selected above...
if ( destination != null ) {
// Update input path
dlg.destination.input.text = destination.fsName;
}

}

dlg.export.save.onClick = function() {

save = true;
dlg.close();

}

dlg.export.cancel.onClick = function() {

cancel = true;
dlg.close();

}

// Show dialog
dlg.show();


}

function savePSD( doc, docName, docPath, tempDoc ) {

// Options for the psd file
var psd_Opt = new PhotoshopSaveOptions();

psd_Opt.layers = true; // Keep layers
//
// Save active document to the selected destination
tempDoc.saveAs( File( dlg.destination.input.text + '/' + dlg.filename.input.text + '.psd' ), psd_Opt, true );

app.beep();

}

10% popularity Vote Up Vote Down


 

@Gloria351

I use a very helpful action, almost every day.
github.com/jasonlong/Photoshop-Web-Workflow
You can select the layers you want, hit F1, and they will all be exported to a new window. You can save the document, export them for web, etc.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme