Asked
Updated
Viewed
35.2k times

Is is possible to repeat an action in Photoshop X number of times within the same file automatically, without pressing play each time? If so, how?

  • 0
    Do you want to repeat an action across multiple layers? You can record playing an action as an action. Maybe you could experiment with that. Otherwise, you can set a keystroke as a trigger. That would save you from clicking "play", at least. — digitalMedia
  • 0
    Would probably help get a better answer if we knew why you wanted to perform the same action on a single file multiple times. Personally I can't think of why you would. Now, on the other hand I am quite used to performing the same action on multiple files within a folder. To do that go to File > Automate > Batch and configure your batch. The files in the folder (and subfolders as the case may be) need to be named sequentially in order to run a batch, e.g. 1, 2, 3, 4, etc. — Mark Bowker
add a comment
0

5 Answers

  • Votes
  • Oldest
  • Latest
Answered
Updated

Yes, you can. Here is a script, put this in a file called RunActionX-Times.jsx and copy to your Adobe Photoshop > Presets > Scripts folder. Sorry, I'm not sure where the Scripts folder is on a Mac, but you should be able to find it with no problems.

In Photoshop, your new script should appear under File > scripts. Just type in the number of times you want an action to run and VIOLA! Works like a charm!

#target photoshop
app.bringToFront();
function main(){
var dlg =
"dialog{text:'Script Interface',bounds:[100,100,500,230],"+
"panel0:Panel{bounds:[10,10,390,120] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+
"statictext0:StaticText{bounds:[30,10,160,30] , text:'Run Action X Times..' ,properties:{scrolling:undefined,multiline:undefined}},"+
"Xtimes:EditText{bounds:[200,10,261,30] , text:'1' ,properties:{multiline:false,noecho:false,readonly:false}},"+
"ActionSet:DropDownList{bounds:[10,50,180,70]},"+
"ActionName:DropDownList{bounds:[200,50,370,70]},"+
"button0:Button{bounds:[40,80,140,100] , text:'Ok' },"+
"button1:Button{bounds:[240,80,340,100] , text:'Cancel' }}}";

var win = new Window(dlg,"Action Runner");
win.center();

var actionSets = new Array();
actionSets = getActionSets();
for (var i=0,len=actionSets.length;i<len;i++) {
	item = win.panel0.ActionSet.add ('item', "" + actionSets[i]);      
}; 
win.panel0.ActionSet.selection=0;

var actions = new Array();	
actions = getActions(actionSets[0]);
for (var i=0,len=actions.length;i<len;i++) {
	item = win.panel0.ActionName.add ('item', "" + actions[i]);      
};
win.panel0.ActionName.selection=0;

win.panel0.ActionSet.onChange = function() {
win.panel0.ActionName.removeAll();
actions = getActions(actionSets[parseInt(this.selection)]);
for (var i=0,len=actions.length;i<len;i++) {
	item = win.panel0.ActionName.add ('item', "" + actions[i]);  
	}
	win.panel0.ActionName.selection=0;
};
var done = false; 
    while (!done) { 
      var x = win.show(); 
      if (x == 0 || x == 2) {
        win.canceled = true;
        //Cancelled
        done = true; 
      } else if (x == 1) { 
        done = true; 
       var result = valiDate();
        if(result != true) {
        	alert(result);
        	return;
        }else
        {
			var XTimes = parseInt (win.panel0.Xtimes.text);
			for (var a =0;a<XTimes;a++){
        doAction(win.panel0.ActionName.selection.text, win.panel0.ActionSet.selection.text);
			}
        }
      } 
   } 
}

main();

function valiDate(){

return true;
};

function getActionSets() { 
cTID = function(s) { return app.charIDToTypeID(s); }; 
sTID = function(s) { return app.stringIDToTypeID(s); }; 
  var i = 1; 
  var sets = [];  
  while (true) { 
    var ref = new ActionReference(); 
    ref.putIndex(cTID("ASet"), i); 
    var desc; 
    var lvl = $.level; 
    $.level = 0; 
    try { 
      desc = executeActionGet(ref); 
    } catch (e) { 
      break;    // all done 
    } finally { 
      $.level = lvl; 
    } 
    if (desc.hasKey(cTID("Nm  "))) { 
      var set = {}; 
      set.index = i; 
      set.name = desc.getString(cTID("Nm  ")); 
      set.toString = function() { return this.name; }; 
      set.count = desc.getInteger(cTID("NmbC")); 
      set.actions = []; 
      for (var j = 1; j <= set.count; j++) { 
        var ref = new ActionReference(); 
        ref.putIndex(cTID('Actn'), j); 
        ref.putIndex(cTID('ASet'), set.index); 
        var adesc = executeActionGet(ref); 
        var actName = adesc.getString(cTID('Nm  ')); 
        set.actions.push(actName); 
      } 
      sets.push(set); 
    } 
    i++; 
  } 
  return sets; 
}; 

function getActions(aset) {
cTID = function(s) { return app.charIDToTypeID(s); }; 
sTID = function(s) { return app.stringIDToTypeID(s); };
  var i = 1;
  var names = [];
  if (!aset) {
    throw "Action set must be specified";
  }  
  while (true) {
    var ref = new ActionReference();
    ref.putIndex(cTID("ASet"), i);
    var desc;
    try {
      desc = executeActionGet(ref);
    } catch (e) {
      break;    // all done
    }
    if (desc.hasKey(cTID("Nm  "))) {
      var name = desc.getString(cTID("Nm  "));
      if (name == aset) {
        var count = desc.getInteger(cTID("NmbC"));
        var names = [];
        for (var j = 1; j <= count; j++) {
          var ref = new ActionReference();
          ref.putIndex(cTID('Actn'), j);
          ref.putIndex(cTID('ASet'), i);
          var adesc = executeActionGet(ref);
          var actName = adesc.getString(cTID('Nm  '));
          names.push(actName);
        }
        break;
      }
    }
    i++;
  }
  return names;
};
add a comment
1
Answered
Updated

You have a few options:

  1. You can add the action X number of times when you build the action
  2. You can use applescript or automator to run the action for you (if on a Mac)
add a comment
0
Answered
Updated

I am having the same issue as I want to apply a lens blur in all frames of a video. I want to share my approach and how I solved the problem of repeating the same action multiple times using Adobe Photoshop:

  1. Explored using an external macro tool to repeat actions.
  2. Attempted do call the same action inside itself (recursion), but Photoshop has protections in place to prevent that.
  3. Created an action 1 that plays action 2, and action 2 plays action 1 (trickier attempt at recursion), but Photoshop’s protections still caught this.
  4. Created an action that applies the filter and moves to the next frame; then created action 2 which plays the filter action twice; then created action 3 which plays action 2 twice; then created action 4 which plays actuon 3 twice, and so on. Each nesting of actions has an exponential effect 2^x. With all these in ola e you only have to modify the first action to change what you need to repeat as all of the looping actions will still remain.

My last attempt is what I ended up going with as you can very quickly create enough iterations of loops to have actions repeat thousands of times.

  • 0
    Why don't you use flash, it will give you better depth on the animation. — Zealous
  • 1
    I'd suggest using a tool made for video like After Effects. Then you just decide how long a flare should exist and your done. This kind of goes for the whole topic, if you want an effect in animation/video then using Photoshop is a somewhat clumsy way to do it. Everything from colorizing to PS filters are available in After Effects and you can animate the effect over time making it look a lot more realistic. — graphixboy
add a comment
0
Answered
Updated

My workaround, after settling on an action, is to export the video as an image sequence. Once done, you can file > automate > batch your action to effect all of the images within the folder just created. After your automated action is complete, you'll need to reassemble the sequence in Adobe Photoshop, After Effects, and/or Quicktime and then export in the codec of your choice.

It's a pain, but less painful than click-frame forward-click-frame forward-click ad nauseam.

  • 0
    There is a script that once installed let's you repeat an action the number of times that you type (so if you add a "next frame" action at the end, it will do the work). Don't have the name right now, but if you want I'll post it here. — jozemaner
add a comment
0
Answered
Updated

If you select one or more action steps and drag them onto the new action icon, it will duplicate them. If you have a very slow action like I do, this is much faster than recording it over and over.

add a comment
0