Copy link to clipboard
Copied
Say I have multiple layers in a document. I right click a layer, go to duplicate, select new document. Is there a way to select multiple layers, and then duplicate them to *unique* documents? As in, I select 4 layers, and I duplicate them all at once to 4 new documents?
@CottonandTwirls ā As I think about this, an action might be able to do so, however, it would be messy... Here is a script that should achieve what you are looking for:
/*
https://community.adobe.com/t5/photoshop-ecosystem-discussions/can-you-select-multiple-layers-in-a-document-and-have-them-all-duplicate-to-unique-documents/td-p/12957700
Dupe Selected Layers to New Docs.jsx
v1.0 - Stephen Marsh, 22nd May 2022
Note: No checks are performed for the selected layer kind, ensure that the correct
...
Copy link to clipboard
Copied
Hi, you can use the move tool to do this use the auto-select option then you can select all layers by selecting them from the main working area then control + j to duplicate them at once...regards
Copy link to clipboard
Copied
@CottonandTwirls - yes, this is possible with scripting.
@lambiloon - how does this dupe to separate individual documents?
Copy link to clipboard
Copied
Only with script as suggested by @Stephen_A_Marsh, there isn't built in functionality as far as I know.
Copy link to clipboard
Copied
@CottonandTwirls ā As I think about this, an action might be able to do so, however, it would be messy... Here is a script that should achieve what you are looking for:
/*
https://community.adobe.com/t5/photoshop-ecosystem-discussions/can-you-select-multiple-layers-in-a-document-and-have-them-all-duplicate-to-unique-documents/td-p/12957700
Dupe Selected Layers to New Docs.jsx
v1.0 - Stephen Marsh, 22nd May 2022
Note: No checks are performed for the selected layer kind, ensure that the correct layers are selected!
*/
#target photoshop
function main() {
var s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var lrs = executeActionGet(r).getList(p),
sel = new ActionReference();
for (var i = 0; i < lrs.count; i++) {
sel.putIdentifier(s2t('layer'), p = lrs.getReference(i).getIdentifier(s2t('layerID')));
(r = new ActionReference()).putIdentifier(s2t('layer'), p);
(d = new ActionDescriptor()).putReference(s2t("target"), r);
executeAction(s2t('select'), d, DialogModes.NO);
// Set the parent doc
var origDoc = activeDocument;
// RegEx remove illegal filename characters from document name
var docName = activeDocument.activeLayer.name.replace(/[:\/\\*\?\"\<\>\|\\\r\\\n.]/g, ""); // "/\:*?"<>|\r\n" -> "-";
// Layer name
var layerName = activeDocument.activeLayer.name;
// Show only the current layer
toggleActiveLayerVisibility(true);
// Duplicate the current layer to a new doc
dupeLayer();
// Return to the parent doc
activeDocument = origDoc;
}
/* Functions */
// Dupe active layer to new doc
function dupeLayer() {
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var reference = new ActionReference();
var reference2 = new ActionReference();
reference.putClass(s2t("document"));
descriptor.putReference(s2t("null"), reference);
// Duped document name
descriptor.putString(s2t("name"), docName);
reference2.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
descriptor.putReference(s2t("using"), reference2);
// Duped layer name
descriptor.putString(s2t("layerName"), layerName);
descriptor.putInteger(s2t("version"), 0);
executeAction(s2t("make"), descriptor, DialogModes.NO);
}
// Toggle active layer visibility
function toggleActiveLayerVisibility(toggleOptionsPalette) {
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var list = new ActionList();
var reference = new ActionReference();
reference.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
list.putReference(reference);
descriptor.putList(s2t("null"), list);
descriptor.putBoolean(s2t("toggleOptionsPalette"), toggleOptionsPalette);
executeAction(s2t("show"), descriptor, DialogModes.NO);
}
}
app.activeDocument.suspendHistory("Dupe Selected Layers to New Docs.jsx", "main()");
Saving & Installing Scripts:
More here:
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html#Photoshop
Copy link to clipboard
Copied
Stephen I cannot express my gratitute enough to you for the various scripts you've written that have saved me literally HOURS of work. I just started using your rename-multiple-layers-at-once script last week and I went around and told every single person I know who uses Photoshop where to find it lol. Thank you, once again. This works perfectly.
Copy link to clipboard
Copied
@CottonandTwirls ā You're welcome, I'd like to think that I am helping to pay back to the community in the same spirit in which others have helped me.