Skip to main content
Stephen Marsh
Community Expert
Community Expert
March 29, 2016
Question

Loop through action sets to save individual actions?

  • March 29, 2016
  • 2 replies
  • 910 views

Just wondering if anybody knows of a script that would cycle through all the loaded action sets in the actions palette and save them out as individual ATN files?

I found one of Xbytor’s Xtools scripts to make a backup of the Actions Palette.psp file, however I was looking for something a little more granular…

This topic has been closed for replies.

2 replies

Inspiring
March 30, 2016

Let me look at it again and see if there is something I messed up. PM me your email address and I'll send you a working file sometime later today or tomorrow.

BTW, you could run BackupActions.js then the unedited ActionsPaletteToFiles.jsx to get the same effect. The only problem with BackupActions is that it doesn't recognize any new actions created since you started your current PS session.

-X

Stephen Marsh
Community Expert
Community Expert
March 30, 2016

Thanks xbytor, I have 69 actions loaded (some very complex) and the unedited script locks up with spinning wheel of death when it has only saved on 2-3 actions (tried in both CS6 and CC15).

Inspiring
March 30, 2016

Some Actions take a long time to process because of stuff like embedded color profiles or something similar that is stored as a binary blob which take a lot of time to process. Wait for an hour to see if they make progress. If not, send me a .psp file to play with.

-X

Inspiring
March 29, 2016

Edit the ActionsPaletteToFiles.jsx script. Replace the existing main() function with this code below. I've added a new flag, USE_RUNTIME_PALETTE, that will force the script to read the runtime palette instead of prompting for a file. In the code below, I have the flag turned on. When I push this out to sourceforge and in future xtools releases, this flag will be turned off. Eventually I'll just add a button to the UI.

-X

EDIT: removed some $.writeln() calls.

USE_RUNTIME_PALETTE = true;

function main() {
  if (CSVersion() < 2) {
    alert("Because of missing Javascript APIs, reading binary action files " +
          "is currently only supported in CS2+. Support for CS and possibly " +
          "PS7 may  become available in the future.");
    return;
  }

  var runtime = USE_RUNTIME_PALETTE;
  var test = false;
  var opts;

  Stdlib.log.setFile(Stdlib.PREFERENCES_FOLDER + "/stdout.log");
  Stdlib.log("ExportPalette");

  if (runtime) {
    var fld = Stdlib.selectFolder('Select destination folder for .atn files');
    var iterator = {};
    iterator.exec = function(actSet) {
      var actFile = new ActionFile();
      actFile.actionSet = actSet;
      var nm = actSet.name;
      if (!nm.match(/\.atn$/i)) {
        nm += ".atn";
      }
      actFile.file = new File(this.folder + '/' + nm);
      try {
        actFile.write();
      } catch (e) {
      }
    };

    iterator.folder = fld;
    ap = new ActionsPalette();
    ap.iterateRuntime(iterator);

    return;
  }

  if (!test) {
    var ui = new ExportPaletteUI();
    var opts = ui.run();
  } else {
    opts = {
      source: new File(app.preferencesFolder + "/Actions Palette.psp"),
      output: new Folder("/c/temp")
    };
  }

  if (!opts) {
    return;
  }

  function saveActionSet(actSet) {
    var opts = this.state;
    var actFile = new ActionFile();
    actFile.actionSet = actSet;
    var nm = actSet.name;
    if (!nm.match(/\.atn$/i)) {
      nm += ".atn";
    }
    actFile.file = new File(opts.output + '/' + nm);

    try {
      actFile.write();
    } catch (e) {
    }
  }
  var itr = new ActionsPaletteIterator(opts);
  itr.exec = saveActionSet;
  var palFile = ActionsPaletteFile.iterateOverFile(opts.source, itr);

  return;
};

Stephen Marsh
Community Expert
Community Expert
March 30, 2016

Thank you! Ah, I was referring to “BackupActions.js”, however I had forgotten about “ActionsPaletteToFiles.jsx”…

That sort of worked xbytor, however when loading the action sets back into Photoshop, the actual action steps are missing, the actions are essentially blank/useless…

Perhaps I did not copy/paste correctly?