Rename sub-layers (paths) in Illustrator

New Here ,
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

132

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

1 Correct Answer

Enthusiast , Feb 05, 2021
femkeblanco Enthusiast , 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 } }

Likes

Translate

Translate
Jump to answer Jump to answer
Enthusiast ,
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
    }
}

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
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 ]

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
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

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Feb 06, 2021

Copy link to clipboard

Copied

You are correct. It works perfectly!

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
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.

 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
julieh67877548 AUTHOR LATEST
New Here ,
Feb 06, 2021

Copy link to clipboard

Copied

You are correct. My mistake. It works perfectly! 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more