• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Selecting text layers with effects?

Explorer ,
Jun 09, 2024 Jun 09, 2024

Copy link to clipboard

Copied

Hi again, i was batch resizing some files, and I accidentally forgot to turn on the "scale effects" option, so now I have about 200 files with a few thousand text layers with really small effects, I have a script to correct this and give the proper effects to the layers, but I don't know how to select all the text layers with effects, I thought I could use a conditional on an action for this, but that doesn't work since my documents have layer with and without effects and the action ends up not selecting any layers, so now I dunno what to do T_T
Any idea on how to select all the text layers that have effects? Thanks.

TOPICS
Actions and scripting

Views

78

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Jun 09, 2024 Jun 09, 2024

Copy link to clipboard

Copied

Is it enough to simply run a script over all text layers, whether or not they have fx, or do you have to run on only text layers with fx?

 

Are the text layers top-level only, or inside groups or artboards?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 09, 2024 Jun 09, 2024

Copy link to clipboard

Copied

Yeah, I need to select only the text layers with effects, and all the layers (With or without effects) are inside a folder named "Text" 😕

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 09, 2024 Jun 09, 2024

Copy link to clipboard

Copied

quote

Yeah, I need to select only the text layers with effects, and all the layers (With or without effects) are inside a folder named "Text" 😕


By @Iuigidesu

 

Yes, an action to set the layer style scale will throw up an error if you try to apply it to a layer without a style applied.

 

A script can overcome this, by wrapping the code into a try/catch block. Here is an example of scaling a selected layer 800%, if there's no style applied the error is suppressed:

 

try {
    var idscaleEffectsEvent = stringIDToTypeID("scaleEffectsEvent");
    var desc548 = new ActionDescriptor();
    var idscale = stringIDToTypeID("scale");
    var idpercentUnit = stringIDToTypeID("percentUnit");
    desc548.putUnitDouble(idscale, idpercentUnit, 800.000000);
    executeAction(idscaleEffectsEvent, desc548, DialogModes.NO);
} catch (e) { }

 

However, by adding a check for the existence of a layer style (see below), the try/catch becomes a redundant fallback.

 

You can record the following script into an action, and then run the action via batch. Simply change the value of 800 to your desired % value. The script will process all top-level/root text layers with styles or text layers with styles residing inside groups or nested groups:

 

/*
Scale Layer Style Effects For All Text Layers.jsx
v1.0, 10th June 2024, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/selecting-text-layers-with-effects/td-p/14671058
*/

#target photoshop

var theValue = 800; // Layer style % 

if (!documents.length) {
    alert('There are no documents open!');
} else {
    processAllLayersAndSets(app.activeDocument);
}

function processAllLayersAndSets(obj) {
    // Process Layers 
    for (var i = obj.artLayers.length - 1; 0 <= i; i--) {
        app.activeDocument.activeLayer = obj.artLayers[i];
        if (app.activeDocument.activeLayer.kind == LayerKind.TEXT && haslayerEffects() === true) {
            scaleEffectsEvent(theValue);
        }
    }
    // Process Layer Set Layers 
    for (var j = obj.layerSets.length - 1; 0 <= j; j--) {
        processAllLayersAndSets(obj.layerSets[j]);
    }
}

function scaleEffectsEvent(theScale) {
    try {
        var s2t = function (s) {
            return app.stringIDToTypeID(s);
        };
        var descriptor = new ActionDescriptor();
        descriptor.putUnitDouble(s2t("scale"), s2t("percentUnit"), theScale);
        executeAction(s2t("scaleEffectsEvent"), descriptor, DialogModes.NO);
    } catch (e) {}
}

function haslayerEffects() {
    // by greless
    // returns true or false
    try {
        var r = new ActionReference();
        r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
        var options = executeActionGet(r);
        return options.hasKey(stringIDToTypeID("layerEffects"));
    } catch (e) { }
}

 

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

 

P.S. If your action needs to do more than only adjust the layer style scale, then the script function above could be changed to run an action instead.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 09, 2024 Jun 09, 2024

Copy link to clipboard

Copied

LATEST

"I thought I could use a conditional on an action for this, but that doesn't work since my documents have layer with and without effects and the action ends up not selecting any layers"

 

It does not work if you use condition Layer Has Effects > Then Play Action: Action to run script or else Play Action: > None?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines