Skip to main content
Participant
December 15, 2024
Answered

Apply Last Filter to each Selected Smart Object at once?

  • December 15, 2024
  • 1 reply
  • 359 views

Hello everyone! I did searching for many way to do this, I even created actions, but there's many individual Layers/Smart Objects (>400 Layers per File) that I can not do it one by one anymore 😞 Is there a way that could apply Last Filter (Ctrl+Alt+F) to selected layers without convert them into one SO?

This topic has been closed for replies.
Correct answer Stephen Marsh

If you record the filter into an action, then the following scripts work on 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);
        //d.putBoolean(s2t("makeVisible"), false);
        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) }

1 reply

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
December 15, 2024

If you record the filter into an action, then the following scripts work on 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);
        //d.putBoolean(s2t("makeVisible"), false);
        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) }
Participant
December 15, 2024

Thank you so much! Although it's quite inconvenient while I have to record new actions, and have to browse script every time despite of loading it as an action, but it really saved me a lot of time

Stephen Marsh
Community Expert
Community Expert
December 15, 2024

@ydntdajlia_5882 – The script can either be manually browsed each time from File > Scripts > Browse... or permanently installed into the File > Scripts menu by placing the .jsx file into the application folder's Presets/Scripts directory. As you mentioned, one can also record the script's execution into an action.

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html