Copy link to clipboard
Copied
Hello, Can someone explain to me - who does not yet know how to use scripts in Photoshop - how to get one action to play on multiple layers in photoshop? Right now, I am creating an action and then running it one by one through all the layers I'd like it to apply to. thanks.
Copy link to clipboard
Copied
@ilanas2487258 - There are many examples in the forum if you search.
The following script requires you to hard-code the action set and action into the script code for selected layers:
//Jazz-y
// Run currently selected action on selected layers.jsx
#target photoshop
var s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var lrs = executeActionGet(r).getList(p);
(r = new ActionReference()).putEnumerated(s2t('action'), s2t('ordinal'), s2t('targetEnum'));
try {
try {
var atn = executeActionGet(r).getString(s2t('name')),
set = executeActionGet(r).getString(s2t('parentName'));
}
catch (e) { throw 'Before start select any action from actions palette!' }
for (var i = 0; i < lrs.count; i++) {
(r = new ActionReference()).putIdentifier(s2t('layer'), lrs.getReference(i).getIdentifier(s2t('layerID')));
(d = new ActionDescriptor()).putReference(s2t('target'), r);
try { executeAction(s2t('select'), d, DialogModes.NO); } catch (e) { throw e + '\nCannot select layer!' }
(r = new ActionReference()).putName(s2t('action'), atn);
r.putName(s2t('actionSet'), set);
(d = new ActionDescriptor()).putReference(s2t('target'), r);
try { executeAction(s2t('play'), d) } catch (e) { throw e + '\nCannot play action "' + atn + '" from set "' + set + '"' }
}
} catch (e) { alert(e) }
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
Copy link to clipboard
Copied
There are conditional actions which can do the job sometimes. Because of limited set of conditions you could check fro Background layer, for example and stop running action.
Here is scenario:
You have Background layer and 10 other layers.
Record action to do something to layer. Thats Action 1. (Action select subject in my screenshot)
Record another action, this is action 2:
step 1 to select bottom most layer (or Background layer) then to select next layer.
step 2 this step should check whether selected layer is Background layer. If yes then do nothing. If selected layer is not Background layer then play Action 1.
step 3 Record step to select next layer .
Duplicate steps 2 and 3 multiple times or as many as you want because when cycling through layers and playing Action 1 hits Background layer it will stop executing, actually it will do nothing.
You can think further about scenarios and how to use conditional actions, the only limitation is restrictive set of conditions. For now you have script which is more powerful and think no more, actions can not do what script can. I am trying to help solve problem when in rush or no script available.