Skip to main content
Known Participant
April 25, 2026
Question

Replay an action more than once.

  • April 25, 2026
  • 3 replies
  • 26 views

Running a action more than once. I had this working prior to upgrading windows 11 home to pro and had to reload all apps. I redone this action of image size and run it more than once but now it will only play once. I set a size 110% then press the play until I am happy with the size but now it plays once only. So what I missed I am unsure. 

    3 replies

    Stephen Marsh
    Community Expert
    Community Expert
    April 26, 2026

     

     

    // Repeat action N times scriptUI GUI.jsx
    // v1.1 - 13th October 2024, Stephen Marsh
    // Based on:
    // https://community.adobe.com/t5/photoshop-ecosystem-discussions/repeat-action-x-times/m-p/14840325


    #target photoshop

    // Create the ScriptUI dialog
    var dlg = new Window('dialog', 'Repeat Action N Times (v1.1)');
    dlg.orientation = "column";
    dlg.alignChildren = ["fill", "top"];
    dlg.spacing = 10;
    dlg.margins = 16;

    // Dropdown for parent action sets
    dlg.add('statictext', undefined, 'Select Action Set:');
    var actionSetDropdown = dlg.add('dropdownlist');
    actionSetDropdown.selection = 0;

    // Dropdown for child actions
    dlg.add('statictext', undefined, 'Select Action:');
    var actionDropdown = dlg.add('dropdownlist');

    // Input for number of repetitions
    var inputGroup = dlg.add("group");
    inputGroup.orientation = "row";
    inputGroup.alignChildren = ["fill", "center"];
    inputGroup.spacing = 10;
    var inputLabel = inputGroup.add("statictext", undefined, "Repeat Count:");
    var inputField = inputGroup.add("editnumber", undefined, "2");
    inputField.characters = 10;

    // OK and Cancel buttons
    var btnGroup = dlg.add('group');
    btnGroup.orientation = "row";
    btnGroup.alignChildren = ["fill", "center"];
    btnGroup.spacing = 10;
    var cancelBtn = btnGroup.add('button', undefined, 'Cancel');
    var okBtn = btnGroup.add('button', undefined, 'OK', { name: "ok" });

    // Make buttons equal width
    okBtn.size = cancelBtn.size = [100, 30];

    // Function to get available action sets
    function getActionSets() {
    var actionSets = [];
    var setCounter = 1;
    while (true) {
    try {
    var ref = new ActionReference();
    ref.putIndex(charIDToTypeID("ASet"), setCounter);
    executeActionGet(ref);
    var desc = executeActionGet(ref);
    actionSets.push(desc.getString(charIDToTypeID("Nm ")));
    setCounter++;
    } catch (e) {
    break;
    }
    }
    return actionSets;
    }

    // Function to get actions from a specific action set
    function getActions(actionSet) {
    var actions = [];
    var actionCounter = 1;
    while (true) {
    try {
    var ref = new ActionReference();
    ref.putIndex(charIDToTypeID("Actn"), actionCounter);
    ref.putName(charIDToTypeID("ASet"), actionSet);
    var desc = executeActionGet(ref);
    actions.push(desc.getString(charIDToTypeID("Nm ")));
    actionCounter++;
    } catch (e) {
    break;
    }
    }
    return actions;
    }

    // Populate the action set dropdown
    var actionSets = getActionSets();
    for (var i = 0; i < actionSets.length; i++) {
    actionSetDropdown.add('item', actionSets[i]);
    }

    // Select the first action set by default
    if (actionSets.length > 0) {
    actionSetDropdown.selection = 0;

    // Populate the actions dropdown with actions from the first set
    var firstSetActions = getActions(actionSets[0]);
    for (var i = 0; i < firstSetActions.length; i++) {
    actionDropdown.add('item', firstSetActions[i]);
    }

    // Select the first action by default
    if (firstSetActions.length > 0) {
    actionDropdown.selection = 0;
    }
    }

    // When the action set is changed, update the action dropdown
    actionSetDropdown.onChange = function () {
    actionDropdown.removeAll();
    if (actionSetDropdown.selection) {
    var actions = getActions(actionSetDropdown.selection.text);
    for (var i = 0; i < actions.length; i++) {
    actionDropdown.add('item', actions[i]);
    }
    if (actions.length > 0) {
    actionDropdown.selection = 0;
    }
    }
    };

    // OK button behavior
    okBtn.onClick = function () {
    var inputValue = parseInt(inputField.text);
    if (isNaN(inputValue) || inputValue < 1) {
    alert("Please enter a valid whole number greater than 0 for repetitions.");
    return;
    }
    if (actionSetDropdown.selection && actionDropdown.selection) {
    dlg.close();
    executeActionMultipleTimes(actionDropdown.selection.text, actionSetDropdown.selection.text, inputValue);
    } else {
    alert("Please select both an Action Set and an Action.");
    }
    };

    // Cancel button behavior
    cancelBtn.onClick = function () {
    dlg.close();
    };

    // Function to execute the selected action multiple times
    function executeActionMultipleTimes(actionName, actionSet, count) {
    try {
    app.doProgress("Executing action '" + actionName + "' " + count + " times", "executeActionProgress('" + actionName + "', '" + actionSet + "', " + count + ")");
    } catch (e) {
    alert("Error executing action: " + e);
    }
    }

    function executeActionProgress(actionName, actionSet, count) {
    for (var i = 0; i < count; i++) {
    app.doProgress("Execution " + (i + 1) + " of " + count, "app.doAction('" + actionName + "', '" + actionSet + "')");
    if (app.playbackDisplayDialogs == DialogModes.ALL) {
    app.changeProgressText("Action '" + actionName + "' completed " + (i + 1) + " of " + count + " times");
    }
    }
    }

    // Show the dialog
    dlg.layout.layout(true);
    dlg.layout.resize();
    dlg.center();
    dlg.show();

     

    Stephen Marsh
    Community Expert
    Community Expert
    April 26, 2026

    @Bentley B 

     

    An action can certainly do this, however, this is something that is more flexible with scripting.

     

    It’s hard to comment without seeing the expanded action steps.

     

    I’ll post the scripts.

     

    On your particular use case, there was a brief period where “stair interpolation” for upsizing was briefly popular (around 2002), however, it’s now generally accepted that resizing in a single step is better, YMMV.

     

     

    Trevor.Dennis
    Community Expert
    Community Expert
    April 25, 2026

    I’m guessing it will be something to do with the end state of the action, but I can’t think how an action that used to work before a Windows update now doesn’t.  Does the action use any shortcuts perhaps?  Shortcuts can depend on which workspace you are using.

     

    Windows updates can certainly be a PITA.  I could not get iTunes to see my iPhone last night, but the phone invited me to trust the computer, so the cable was OK.  It turned out that Windows had arbitrarily installed Apple Devices on my Windows 11 system.  Removing that from Settings > Apps > Installed Apps fixed the problem.  It might have been an iCloud update and not Windows, but it’s annoying how something you have used for years becomes broken through a mega corporation’s attempt at controlling how you work.