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

Rename the layer using the name of the enclosed object

Community Beginner ,
Feb 17, 2014 Feb 17, 2014

I'm trying to build a map of the world that includes provinces and sub-provinces (counties).  I will be animating it in AE. AE only sees the top layers so it is imparative that the name of the top layer corresponds the the correct province. Unfortunately all the provinces are not layers. They are objects. I can use the "Release to Layers" command to get all objects nested into top level layers. But the top level layers have generic names (Layer 1, Layer2, Layer 3). The objects nested within these layers have the correct name.

Is there a script that will rename the top level layer using the name given to the object nested within that layer? If not, could would sombody be willing to help create one.

Here's a link to one of the files: world_all_provinces_Senegal divisions. Level 1_area.zip

layer_naming_problem.png

TOPICS
Scripting
2.0K
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

correct answers 1 Correct answer

Mentor , Feb 17, 2014 Feb 17, 2014

Opps, I am too slow.

I could not open your file to test this, but in a quick test this seemed to work also.

1.png

var doc = app.activeDocument;

var n, p;

for (var i = 0, l = doc.pageItems.length; i < l; i++) {

    p = doc.pageItems;

    n = p.name;

    p.parent.name = n;

}

2.png

But again maybe it's to specific (not tested with your file or others) and thus wont work in your case or others. Worth a shot I guess though.

Translate
Adobe
Engaged ,
Feb 17, 2014 Feb 17, 2014

Post 3 here might be a good starting point for you.

http://forums.adobe.com/message/4779181#4779181

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
Community Expert ,
Feb 17, 2014 Feb 17, 2014

here's a script for the same request you have

http://forums.adobe.com/thread/877442?

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
Mentor ,
Feb 17, 2014 Feb 17, 2014

Opps, I am too slow.

I could not open your file to test this, but in a quick test this seemed to work also.

1.png

var doc = app.activeDocument;

var n, p;

for (var i = 0, l = doc.pageItems.length; i < l; i++) {

    p = doc.pageItems;

    n = p.name;

    p.parent.name = n;

}

2.png

But again maybe it's to specific (not tested with your file or others) and thus wont work in your case or others. Worth a shot I guess though.

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
Community Beginner ,
Feb 17, 2014 Feb 17, 2014

W_J_T wrote:

Opps, I am too slow.

I could not open your file to test this, but in a quick test this seemed to work also.

1.png

var doc = app.activeDocument;
var n, p;
for (var i = 0, l = doc.pageItems.length; i < l; i++) {
    p = doc.pageItems;
    n = p.name;
    p.parent.name = n;
}

2.png

But again maybe it's to specific (not tested with your file or others) and thus wont work in your case or others. Worth a shot I guess though.

Wow! Thanks W_J_T! The script works perfectly! This is going to save me a ton of time seeing that I have thousands of 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
Mentor ,
Feb 17, 2014 Feb 17, 2014

naming&renaming wrote:

Wow! Thanks W_J_T! The script works perfectly! This is going to save me a ton of time seeing that I have thousands of layers.

You're welcome.

However please note: That It only works "perfect" in this specific situation. If there are groups, or multiple sub layers then it wont work properly, its a kind of a dirty solution but it works in this case.
I am glad to hear however that it was helpful for your specific needs, as renaming thousands of layers manually does not sound like fun. 😉

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
Explorer ,
Feb 05, 2019 Feb 05, 2019
LATEST

I know this is an old thread, but thank you so much W_J_T! I am using CCv2018 and your script works a treat! It will be invaluable to me as I prep a few hundred layers for animating in AE

Ellen

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