@WordWeaver wrote:
So, what is the secret for accomplishing this simple task?
Scripting is the secret!

An action can repeat a fixed amount of times, so it has limitations. A script can use a variable rather than a fixed value.
/*
Repeat Layer.jsx
v1.0 - Stephen Marsh, 14th January 2022
Note: No check is performed against the layer kind
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-drawl-in-multiple-layers-in-photoshop/td-p/12657971
*/
#target photoshop
function main() {
if (app.documents.length > 0) {
// Loop the input prompt until a number is entered
var userInput;
while (isNaN(userInput = prompt("Enter the layer repeat quantity required:", "2")));
// Test if cancel returns null, then terminate the script
if (userInput === null) {
//alert('Script cancelled!');
return
}
// Test if an empty string is returned, then repeat
while (userInput.length === 0) {
userInput = prompt("Blank value not accepted, please enter the layer repeat quantity required:", "");
}
// Convert decimal input to integer
var dupeValue = parseInt(userInput);
// Iterate the dupe
for (var i = 0; i < dupeValue; i++) {
// Select front layer hack to control layer creation order
var idselect = stringIDToTypeID("select");
var desc1307 = new ActionDescriptor();
var idnull = stringIDToTypeID("null");
var ref436 = new ActionReference();
var idlayer = stringIDToTypeID("layer");
var idordinal = stringIDToTypeID("ordinal");
var idfront = stringIDToTypeID("front");
ref436.putEnumerated(idlayer, idordinal, idfront);
desc1307.putReference(idnull, ref436);
var idmakeVisible = stringIDToTypeID("makeVisible");
desc1307.putBoolean(idmakeVisible, false);
var idlayerID = stringIDToTypeID("layerID");
var list112 = new ActionList();
list112.putInteger(26);
desc1307.putList(idlayerID, list112);
executeAction(idselect, desc1307, DialogModes.NO);
// Duplicate layer
app.activeDocument.activeLayer.duplicate();
}
// Select the top layer
app.activeDocument.activeLayer = app.activeDocument.layers[0];
} else {
alert('A document must be open to use this script!');
}
}
app.activeDocument.suspendHistory("Repeat Layer.jsx", "main()");
Instructions:
- Copy the code text to the clipboard
- Open a new blank file in a plain-text editor (not word-processor)
- Paste the code in
- Save the text file as Repeat Layer.txt
- Rename the file extension from .txt to .jsx
- Install or browse to the .jsx file to run