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

How to disable auto rename text layer with content

New Here ,
Mar 13, 2013 Mar 13, 2013

HI Every one,

I want to disable the auto renaming feature in text layers so that I can change the content without change the name of the text layer.

also i want to do this to all the text in one step, wthout do it manual one by one.

for more description, i am working on replace English text with other language but i want to keep English name of all text layers SO i want to disable auto renaming while replacing the content.

 

I guess a Script could do this by changing the names (adding a space or a _ for example)

Thanks in advance


  

TOPICS
Actions and scripting
3.2K
Translate
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
Guru ,
Mar 13, 2013 Mar 13, 2013

You don't need to add a prefix/suffix to the layer name. All you have to do is name the layer. Photoshop by default names a text layer with at least part of the text contents. When the contents is changed Photohop updates the layer name. To stop the auto-updating of the layer name you just need to name the layer. Photoshop will not update a named layer.

Are any of the text layers in layerSets? The code are looping layers is different if there are layerSets in the document.

Translate
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
New Here ,
Mar 13, 2013 Mar 13, 2013

Dear Michael

Thanks for your advice but i need to do this in all the text layers in one step, I have 50+ test layer I want to stop the update process and keep the name of the text layer the same.

Translate
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
Guru ,
Mar 13, 2013 Mar 13, 2013

kenrou123 wrote:

Thanks for your advice but i need to do this in all the text layers in one step

I understood that which is why I asked if the layers were in layerSets. I need to know more about how the document is setup before I post any code to rename the layers.

Translate
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
New Here ,
Mar 13, 2013 Mar 13, 2013

Yes I have some of the text layers in layerSets and some without layerSets

Thanks in advance

Translate
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
Valorous Hero ,
Mar 13, 2013 Mar 13, 2013

This should add a space after the layer name...

main();
function main(){
if(!documents.length) return;
var txtLayers = getNamesPlusIDs();
for (var a in txtLayers){
    putLayerNameByID(Number(txtLayers[0]),(txtLayers[1].toString()+' '));
    }
}

function putLayerNameByID( ID, name ) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putIdentifier( charIDToTypeID('Lyr '), ID );
desc.putReference( charIDToTypeID('null'), ref );
var nameDesc = new ActionDescriptor();
nameDesc.putString( charIDToTypeID('Nm  '), name );
desc.putObject( charIDToTypeID('T   '), charIDToTypeID('Lyr '), nameDesc );
executeAction( charIDToTypeID( 'slct' ), desc, DialogModes.NO );
executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
}
function getNamesPlusIDs(){
   var ref = new ActionReference();
   ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
   var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1;
   var Names=[];
try{
    activeDocument.backgroundLayer;
var i = 0; }catch(e){ var i = 1; };
   for(i;i<count;i++){
       if(i == 0) continue;
        ref = new ActionReference();
        ref.putIndex( charIDToTypeID( 'Lyr ' ), i );
        var desc = executeActionGet(ref);
        var layerName = desc.getString(charIDToTypeID( 'Nm  ' ));
        var Id = desc.getInteger(stringIDToTypeID( 'layerID' ));
        if(layerName.match(/^<\/Layer group/) ) continue;
        var layerType = typeIDToStringID(desc.getEnumerationValue( stringIDToTypeID( 'layerSection' )));
        var isLayerSet =( layerType == 'layerSectionContent') ? false:true;
        if(desc.hasKey( stringIDToTypeID( 'textKey' ) ) ) Names.push([[Id],[layerName]]);
   };
return Names;
};

Translate
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
New Here ,
Mar 17, 2013 Mar 17, 2013

Dear Paul

Thanks for you work

your script works very good but I need to remove the space again from all the text layers so that the text layer name remain in its original name without space.

That because I use another script require the text layer name to be the same.

Translate
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
Valorous Hero ,
Mar 17, 2013 Mar 17, 2013
LATEST

You could change line 6 from...

putLayerNameByID(Number(txtLayers[0]),(txtLayers[1].toString()+' '));

To...

putLayerNameByID(Number(txtLayers[0]),(txtLayers[1].toString().replace(/\s$/,'')));

This will remove the space at the end of the layers name.

For future use on different files.

Change that line again so it is setting the name as the name with...

putLayerNameByID(Number(txtLayers[0]),(txtLayers[1].toString()));

Translate
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