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

Script: rename layers?

Community Beginner ,
Feb 15, 2010 Feb 15, 2010

Copy link to clipboard

Copied

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

Views

34.3K

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

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;

     }

}

Votes

Translate

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

Copy link to clipboard

Copied

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...

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

Copy link to clipboard

Copied

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.

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

Copy link to clipboard

Copied

was it the dredded PARM error?

not happy with PARM  

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

Copy link to clipboard

Copied

Sorry, PARM error ?

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

Although, I never got a PARM error.

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