Copy link to clipboard
Copied
Hopefully this is a simple answer! Is it possible to create a single PSD file (with artboards) from multiple PSD files?
Copy link to clipboard
Copied
If you try File > Scripts > Load Files into Stack... with artboards, it'll merge the artboards but place the content of the files on separate layers in a new document. So what you could do instead is first use File > Export > Artboards to Files... and then use File > Scripts > Load Files into Stack.
Copy link to clipboard
Copied
Love the Stack feature but I guess thats not what I'm looking for. I'm trying to combine single PSD files into 1 PSD file that has each collected PSD file as an artboard. Does that make sense?
Copy link to clipboard
Copied
I originally created this script for this topic thread... The following script merges layers to a single layer. If require multi-layered artboards, then the script below is not for you.
/*
Stack Merged Files to Artboards.jsx
v1.1, 31 July 2021 - Artboards are stacked on top of each other for manual arrangement
v1.2, 8th May 2024 - Added code from r-bin to auto arrange the artboards into a grid
v1.3, 9th May 2024 - Added code to set the artboard background colour
By Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem/combining-mulitple-photoshop-files-into-1-photoshop-file-with-artboards/td-p/12218200
NOTE: Does not retain multiple layers!
*/
#target photoshop
try {
if (app.documents.length === 0) {
(function () {
// Capture the original ruler units and set the ruler units to pixels
var origUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
// Select the input folder
var inputFolder = Folder.selectDialog('Please select the input folder:');
// Test if Cancel button returns null, then do nothing
if (inputFolder === null) {
app.beep();
return;
}
// Supported file formats
var inputFiles = inputFolder.getFiles(/\.(jpg|jpeg|tif|tiff|png|psd|psb)$/i);
// Alpha numeric sort
inputFiles.sort().reverse();
// Process the first "base" file
var firstFile = app.open(File(inputFiles[0]));
var firstFileName = app.activeDocument.name;
app.activeDocument.duplicate("Artboard Stack from Files", true);
firstFile.close(SaveOptions.DONOTSAVECHANGES);
var artboardStack = app.activeDocument;
app.activeDocument = artboardStack;
artboardStack.activeLayer.name = firstFileName;
// Call the 1st artboard function
artBoardFromLayers();
artBoardBackground(3);
artboardStack.activeLayer.name = firstFileName.replace(/\.[^\.]+$/, '');
// Process the remaining files to the "base" file
for (var i = 1; i < inputFiles.length; i++) {
var remainingFiles = app.open(File(inputFiles[i]));
if (app.activeDocument.layers.length > 1) {
app.activeDocument.mergeVisibleLayers();
}
var fileName = remainingFiles.name;
remainingFiles.activeLayer.name = fileName;
remainingFiles.layers[0].duplicate(artboardStack, ElementPlacement.PLACEATBEGINNING);
remainingFiles.close(SaveOptions.DONOTSAVECHANGES);
// Call the 2nd artboard function
artBoardFromLayers2();
artBoardBackground(3);
}
// Arrange the artboards to a grid
arrangeArtboards();
// Return the original ruler units
app.preferences.rulerUnits = origUnits;
// End of script
app.beep();
///// Functions /////
function artBoardFromLayers() {
app.runMenuItem(stringIDToTypeID("artboardFromLayersEvent"));
}
function artBoardFromLayers2() {
var artboardFromLayers = stringIDToTypeID("make");
var desc1156 = new ActionDescriptor();
var idnull = stringIDToTypeID("null");
var ref558 = new ActionReference();
var idartboardSection = stringIDToTypeID("artboardSection");
ref558.putClass(idartboardSection);
desc1156.putReference(idnull, ref558);
var idfrom = stringIDToTypeID("from");
var ref559 = new ActionReference();
var idlayer = stringIDToTypeID("layer");
var idordinal = stringIDToTypeID("ordinal");
var idtargetEnum = stringIDToTypeID("targetEnum");
ref559.putEnumerated(idlayer, idordinal, idtargetEnum);
desc1156.putReference(idfrom, ref559);
var idusing = stringIDToTypeID("using");
var desc1157 = new ActionDescriptor();
var idname = stringIDToTypeID("name");
var abName = fileName.replace(/\.[^\.]+$/, '');
desc1157.putString(idname, abName);
var idartboardSection = stringIDToTypeID("artboardSection");
desc1156.putObject(idusing, idartboardSection, desc1157);
var idlayerSectionStart = stringIDToTypeID("layerSectionStart");
desc1156.putInteger(idlayerSectionStart, 3);
var idlayerSectionEnd = stringIDToTypeID("layerSectionEnd");
desc1156.putInteger(idlayerSectionEnd, 4);
var idname = stringIDToTypeID("name");
desc1156.putString(idname, abName);
executeAction(artboardFromLayers, desc1156, DialogModes.NO);
}
function arrangeArtboards() {
/*
https://community.adobe.com/t5/photoshop-ecosystem-discussions/script-to-arrange-artboard-in-grid/td-p/9417657
by r-bin
*/
var abLength = app.activeDocument.layerSets.length;
var clms = 2;
var space_x = 50;
var space_y = 50;
clms = prompt("Arrange " + abLength + " artboards into a grid. \r Enter the number of columns:", clms);
if (clms) {
clms = Number(clms);
var arts = new Array();
var w = 0;
var h = 0;
for (var i = 0; i < activeDocument.layerSets.length; i++) {
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("artboardEnabled"));
r.putIdentifier(stringIDToTypeID("layer"), activeDocument.layerSets[i].id);
if (executeActionGet(r).getBoolean(stringIDToTypeID("artboardEnabled"))) {
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("artboard"));
r.putIdentifier(stringIDToTypeID("layer"), activeDocument.layerSets[i].id);
var rect = executeActionGet(r).getObjectValue(stringIDToTypeID("artboard")).getObjectValue(stringIDToTypeID("artboardRect"));
var l = rect.getDouble(stringIDToTypeID("left"));
var t = rect.getDouble(stringIDToTypeID("top"));
var r = rect.getDouble(stringIDToTypeID("right"));
var b = rect.getDouble(stringIDToTypeID("bottom"));
arts.push([activeDocument.layerSets, [l, t, r, b]]);
var w1 = r - l;
var h1 = b - t;
if (w1 > w) w = w1;
if (h1 > h) h = h1;
}
}
var rows = Math.floor(arts.length / clms);
if (rows * clms < arts.length) ++rows;
var i = 0;
for (var y = 0; y < rows; y++) {
var pos_y = y * (h + space_y);
for (var x = 0; x < clms; x++) {
if (i >= arts.length) break;
activeDocument.activeLayer = arts[x][0][i];
var pos_x = x * (w + space_x);
move(pos_x - arts[x][1][0], pos_y - arts[x][1][1])
i += 1;
}
}
}
function move(x, y) {
try {
var d = new ActionDescriptor();
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
d.putReference(stringIDToTypeID("null"), r);
var d1 = new ActionDescriptor();
d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), x);
d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), y);
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("offset"), d1);
executeAction(stringIDToTypeID("move"), d, DialogModes.NO);
} catch (e) {
throw (e);
}
}
}
})();
function artBoardBackground(artBoardColor) {
/* https://community.adobe.com/t5/photoshop-ecosystem-discussions/setting-artboard-background-to-transparent/m-p/12438157 */
var ideditArtboardEvent = stringIDToTypeID("editArtboardEvent");
var desc520 = new ActionDescriptor();
var idnull = stringIDToTypeID("null");
var ref129 = new ActionReference();
var idlayer = stringIDToTypeID("layer");
var idordinal = stringIDToTypeID("ordinal");
var idtargetEnum = stringIDToTypeID("targetEnum");
var desc521 = new ActionDescriptor();
var idartboard = stringIDToTypeID("artboard");
var idchangeBackground = stringIDToTypeID("changeBackground");
ref129.putEnumerated(idlayer, idordinal, idtargetEnum);
desc520.putReference(idnull, ref129);
// Static options for "Other" idartboardBackgroundType = 4
var idcolor = stringIDToTypeID("color");
var desc523 = new ActionDescriptor();
var idred = stringIDToTypeID("red");
desc523.putDouble(idred, 128.000000);
var idgrain = stringIDToTypeID("grain");
desc523.putDouble(idgrain, 128.000000);
var idblue = stringIDToTypeID("blue");
desc523.putDouble(idblue, 128.000000);
var idRGBColor = stringIDToTypeID("RGBColor");
desc521.putObject(idcolor, idRGBColor, desc523);
var idartboardBackgroundType = stringIDToTypeID("artboardBackgroundType");
// putInteger 1 = White, 2 = Black, 3 = Transparent, 4 = Other
desc521.putInteger(idartboardBackgroundType, artBoardColor);
desc520.putObject(idartboard, idartboard, desc521);
desc520.putInteger(idchangeBackground, 1);
executeAction(ideditArtboardEvent, desc520, DialogModes.NO);
}
} else {
alert('Please close all open files before running this script...');
}
} catch (e) {
alert("Error!" + "\r" + e + ' ' + e.line);
}
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I'll try this out. Thank you.
Copy link to clipboard
Copied
I have updated the script to create artboards using merged layers to a 1.2 version, which now automatically arranges the artboards into a grid!
The following topic contains a new variation of this script that retains multiple layers: