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

Script: rename layers?

Community Beginner ,
Feb 15, 2010 Feb 15, 2010

Hi, is there a quick way how to renumber or batch rename all layers in a file so they would be named in consequent numbers? Doesn't have to start from exact number, I was wondering if maybe there is some sort of script that would help me with that? Thanks Pavel

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

Guru , Feb 16, 2010 Feb 16, 2010

#target illustrator

var docRef = app.activeDocument;

with (docRef) {

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

          layers.name = layers.length - i;

     }

}

Translate
Adobe
Guide ,
Mar 05, 2017 Mar 05, 2017

Just put 2017 on a different machine. this one is a better machine and seems to run 2017 without issues.

new doc, single default layer, run script, press cancel, crash....

So I have no idea what is now broken.

The odd thing is that running it from ESTK does not cause issues and does not crash the software.

I know that ESTK send the script to illustrator via bridgetalk.

not sure if running the script standalone runs it in a different way.

Guess I'll be doing a bit of reading...

StrongBeaver​, if you have ESTK installed, can you try running it from there to see if it still crashes illy.

Makes it very hard to debug when it runs fine from the debugger...

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
Advisor ,
Mar 05, 2017 Mar 05, 2017

I couldn't change the script since in the middle of a design but the script wouldn't run in ESTK due to line 27; which makes me think it may be the cause of the crashes, for me. 

Then again it crashes for you on one or two layers then my theory is wrong.

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
Guide ,
Mar 06, 2017 Mar 06, 2017

was it the dredded PARM error?

not happy with PARM  

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
Advisor ,
Mar 06, 2017 Mar 06, 2017

Sorry, PARM error ?

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
Guide ,
Mar 06, 2017 Mar 06, 2017

Parm error is happily tossed to us by Adobe when something goes wrong.

the details provided with this error are some numbers that mean nothing to adobe.

and it always throws the same error, which is great in helping you find the problem.

to top it off they say that it must be due to poor coding.

I have had sections of code copied straight from the JS Reference that have caused Parm errors on certain files.

the documentation states under known issues:

issue.JPG


http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/illustrator/sdk/CC2017/AI_ScriptGd.pdf

with all that in mind I will go back over the code and check that I don't have any scope oddities

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
Advisor ,
Mar 06, 2017 Mar 06, 2017

Although, I never got a PARM error.

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