Highlighted

Restore Photoshop Text Layer Name Auto-Updating

Explorer ,
Feb 06, 2017

Copy link to clipboard

Copied

Text layers in Photoshop will auto-update the layer name with the text content of the layer unless you manually edit the layer name in the layers panel. Then it retains the manually entered layer name. How would one go about restoring this auto-updating of the layer name to a layer whose name has been manually edited?

Is this possible at all? I've googled this, and everyone says it's not possible to do this manually, but that it might be possible with scripting. Does anyone know?

I know you can duplicate the layer, then re-enter the text, but that gets a bit tricky if your text has multiple fonts and colors.

TOPICS
Actions and scripting

Views

1.8K

Likes

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

Restore Photoshop Text Layer Name Auto-Updating

Explorer ,
Feb 06, 2017

Copy link to clipboard

Copied

Text layers in Photoshop will auto-update the layer name with the text content of the layer unless you manually edit the layer name in the layers panel. Then it retains the manually entered layer name. How would one go about restoring this auto-updating of the layer name to a layer whose name has been manually edited?

Is this possible at all? I've googled this, and everyone says it's not possible to do this manually, but that it might be possible with scripting. Does anyone know?

I know you can duplicate the layer, then re-enter the text, but that gets a bit tricky if your text has multiple fonts and colors.

TOPICS
Actions and scripting

Views

1.8K

Likes

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
Feb 06, 2017 0
Most Valuable Participant ,
Feb 06, 2017

Copy link to clipboard

Copied

If you have not not closed the document if there is a  history state before you changed the layer name you could back up to that point in time. Else I believe its a done deal. You would need to create a new text later to match the existing one.

JJMack

Likes

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
Reply
Loading...
Feb 06, 2017 0
New Here ,
Feb 08, 2017

Copy link to clipboard

Copied

You can try following Script, Tomas Sinkunas do the most of the works, a tribute to Master!

// Script  Auto-Update the layer's name  

// by Du Hui a JS new hand ,

// Most of the following cord was Tomas Sinkunas's   works, I write just one line.

 

(function(){ 

    #target photoshop 

// Collect all text layers in the document 

    var textLayers = getTextLayers(app.activeDocument); 

 

    // Loop through all text layers in the document 

    for (var t = 0, tl = textLayers.length; t < tl ; t ++) { 

     //  get TXTlayer's contents and Assing values to the lyayer's name

               textLayers.name =textLayers.textItem.contents; 

    } 

 

    function getTextLayers (doc, layers) { 

        layers = layers || []; 

        for (var i = 0, il = doc.layers.length; i < il; i ++) { 

            if (doc.layers.typename == "LayerSet") { 

                getTextLayers(doc.layers, layers) 

            } else { 

                if (doc.layers.kind == "LayerKind.TEXT") { 

                    layers.push(doc.layers

                } 

            } 

        } 

        return layers 

    } 

})();

Likes

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
Reply
Loading...
Feb 08, 2017 0
Explorer ,
Feb 08, 2017

Copy link to clipboard

Copied

JJMack: Yeah I thought so

luhuaidan: That's what I have now, renaming the layers to their content. However, it doesn't solve the auto-updating of layername based on text content. Thanks though

Likes

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
Reply
Loading...
Feb 08, 2017 0
Adobe Community Professional ,
Feb 09, 2017

Copy link to clipboard

Copied

Simene, I thought about duplicating the text layer, but in the panel, the text copy gets appended, and future edition of the text does not update it...

BUT! If you duplicate the layer using CMD+J, copy also gets appended, then, if you re-edit that text (selecting, then CMD+enter), the layer name auto updates again. Now, a scripter could use the scriptlistener to find the difference between the duplicate from panel and CMD+J, then update content, delete the original text layer... and it could be automated, no?

Likes

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
Reply
Loading...
Feb 09, 2017 1
Explorer ,
Feb 12, 2018

Copy link to clipboard

Copied

Solution:

1. Highlight the text layer

2. type [ENTER], [Backspace], [ENTER]

3. It will auto update and keep auto updating.

Likes

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
Reply
Loading...
Feb 12, 2018 3
Community Beginner ,
Oct 15, 2020

Copy link to clipboard

Copied

Oh my god, this is exactly what I needed. What a simple solution. Thank you!

Likes

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
Reply
Loading...
Oct 15, 2020 0
Adobe Community Professional ,
Feb 12, 2018

Copy link to clipboard

Copied

var layer0 = app.activeDocument.activeLayer;

var fx = true;

var gr = layer0.grouped;

try { executeAction( charIDToTypeID( "CpFX" ), undefined, DialogModes.NO ); } catch (e) {fx = false;}

var r = new ActionReference();   

r.putProperty(charIDToTypeID("Prpr"), stringIDToTypeID("textKey"));

r.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));

var textKey = executeActionGet(r).getObjectValue(stringIDToTypeID("textKey"));

var r = new ActionReference();

r.putClass(stringIDToTypeID( "textLayer"));

var d = new ActionDescriptor();

d.putReference( charIDToTypeID( "null" ), r );

d.putObject( charIDToTypeID( "Usng" ), stringIDToTypeID( "textLayer"), textKey);

executeAction( charIDToTypeID( "Mk  " ), d, DialogModes.NO );

var layer1 = app.activeDocument.activeLayer;

if (fx) executeAction( charIDToTypeID( "PaFX" ), undefined, DialogModes.NO );

if (!layer1.grouped && gr) layer1.grouped = gr;

layer0.remove();

app.activeDocument.activeLayer = layer1;

Likes

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
Reply
Loading...
Feb 12, 2018 1