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

Rename sub-layers (paths) in Illustrator

Community Beginner ,
Feb 05, 2021 Feb 05, 2021

Copy link to clipboard

Copied

Is there a script out there for renaming sub-layers? I have a huge number of items to rename (to make a wordpress map plugin function) and I can't seem to find something current that actually works. Bonus if it can do prefix/suffix. 

 

I have Illustrator CC 2020. I've tried every script I could find but nothing seems to work for sublayers and not sure if it's because I am not converting the top layer, but rather the <path> under the top layer or if the scripts are just out of date. 

 

For example, chaging <path> to acre or better yet, acre1, acre2, acre3, etc. 

 

acres.png

TOPICS
Scripting

Views

978

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

Guide , Feb 05, 2021 Feb 05, 2021
var paths = app.activeDocument.pathItems;
for (var i = 0; i < paths.length; i++) {
    if (paths[i].parent.name == "acre") {  // container name
        paths[i].name = "acre" + (i + 1);  // path name
    }
}

Votes

Translate

Translate
Adobe
Guide ,
Feb 05, 2021 Feb 05, 2021

Copy link to clipboard

Copied

var paths = app.activeDocument.pathItems;
for (var i = 0; i < paths.length; i++) {
    if (paths[i].parent.name == "acre") {  // container name
        paths[i].name = "acre" + (i + 1);  // path name
    }
}

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 Beginner ,
Feb 06, 2021 Feb 06, 2021

Copy link to clipboard

Copied

Thank you! This is the error I get when trying to execute. 

 

error.png



[ attachment inserted as inline image by moderator ]

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 ,
Feb 06, 2021 Feb 06, 2021

Copy link to clipboard

Copied

This seems to be a "copy-error"

line 1 should begin with

var

and not with

ar

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 Beginner ,
Feb 06, 2021 Feb 06, 2021

Copy link to clipboard

Copied

You are correct. It works perfectly!

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 ,
Feb 06, 2021 Feb 06, 2021

Copy link to clipboard

Copied

You probably did a little mistake when copying and pasting the code, Julie.

 

There is a missing "v" at the beginning of the first line.

 

The script should work if you correct that.

 

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 Beginner ,
Feb 06, 2021 Feb 06, 2021

Copy link to clipboard

Copied

LATEST

You are correct. My mistake. It works perfectly! 

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