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

Is there a script to rename layers from a text file?

New Here ,
Dec 23, 2022 Dec 23, 2022

Copy link to clipboard

Copied

I have seen a lot of scripts that export the layer names to text file, but does anyone know of a script that does the opposite?

 

I would like to rename my layers by importing names from a text file.

 

For example:

  • I have 90 layers called "person shape"
  • I would like to rename the layers "Ann, Barb, Sally, Fred, Mike, Bob"... etc....

 

Does anyone know of a script that can import those words from a text, and rename the layers?

 

Thanks!

TOPICS
Actions and scripting , Windows

Views

888

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 ,
Dec 25, 2022 Dec 25, 2022

Copy link to clipboard

Copied

How (according to which rule) should the script know which layer should receive which new name?

 

For the beginning (rename the active layer):

var newName = "Bob";
activeDocument.activeLayer.name = newName;

 

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
New Here ,
Dec 25, 2022 Dec 25, 2022

Copy link to clipboard

Copied

Hi, Thanks.

 

In my particular case, it does matter which layers get which name. I was just looking for an easy way to assign these names to the 90+ identical layers.

 

Thanks for the start.

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
New Here ,
Dec 25, 2022 Dec 25, 2022

Copy link to clipboard

Copied

* Sorry: Meant to say "it doesn't matter which layers get which names"

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 ,
Dec 25, 2022 Dec 25, 2022

Copy link to clipboard

Copied

Using what @pixxxelschubser posted, there are many scripts posted that show how to read info from a text file. Using a spreadsheet program, you can convert that to a CSV file, import it into a variable, then use the split command to separate the variable into an array with all the names. Then loop through the array to assign them to the layers.

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 ,
Dec 26, 2022 Dec 26, 2022

Copy link to clipboard

Copied

Are your layers pixel layers (art layers)?
Are your layers arranged in a hierarchy (or perhaps deeply nested in different layer sets)?

 

Can you perhaps upload a simplified PSD example (without confidential data) and link it here?

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
New Here ,
Jan 01, 2023 Jan 01, 2023

Copy link to clipboard

Copied

Hi,

 

Thanks for your reply.

 

Yes they are just pixel layers. They are all in one folder, not sorted in any way. And I have a list of names I would like to assign to each layer in no particular order.

 

This is a link to the PSD file and name list - https://1drv.ms/u/s!At5a8ggd7x62hId6-FWXuq2Ni8PBGw?e=gB9KbO

 

The PSD file only has the layers in a folder, and there is an example list of names which I was hoping to apply.

 

Thanks for your help!

 

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
New Here ,
Jan 01, 2023 Jan 01, 2023

Copy link to clipboard

Copied

Ooops, sorry. I didn't realize I could attach files directly to the message..... Here they are below. Thanks again!

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 ,
Jan 01, 2023 Jan 01, 2023

Copy link to clipboard

Copied

There are 95 layers in the group... While the text file has 54 names.

 

How should this mismatch be solved?

 

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
New Here ,
Jan 01, 2023 Jan 01, 2023

Copy link to clipboard

Copied

LATEST

No, I would expand the list of name to match the number of layer at a later point. For now, it's just a test to see how it works.

 

Side question: Is it possible to import the xy values (coordinates) too? So the text has:

 

layer_name_1, x, y

layer_name_2, x, y

layer_name_3, x, y

....etc

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