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

Find and rename all textFrames having the same name

Engaged ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

Hi,

At activedocument there is multiple textFrames named "Text"

I want to rename each one  to Text0, Text1, Text2

This is not wotking

 

#target illustrator
var SearchName = "Text";
var count = 0;
var textObjects = app.activeDocument.textFrames
for (var i = 0; i < textObjects.length; i++) {
if (textObjects[i].getByName(SearchName) {
textObjects[i].name = SearchName + count ;
 count ++;
}
}

 

 

TOPICS
Scripting

Views

216

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

Community Expert , Jun 15, 2022 Jun 15, 2022

Hell, Try following

 

#target illustrator

var SearchName = "Text";
var count = 0;
var textObjects = app.activeDocument.textFrames
for (var i = 0; i < textObjects.length; i++) {
    if (textObjects[i].name == SearchName) {
        textObjects[i].name = SearchName + count;
        count++;
    }
}

Error in in your versions:
1. Round bracket missing in if statement

2. You are using the getByName on each textFrame like textFrame[i], instead it should be textFrames.getByNamewithout i.

 

Votes

Translate

Translate
Adobe
Guide ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

You are looping through textFrames, not pathItems.

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
Engaged ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

Sorry!
I mean textFrames

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 ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

Hell, Try following

 

#target illustrator

var SearchName = "Text";
var count = 0;
var textObjects = app.activeDocument.textFrames
for (var i = 0; i < textObjects.length; i++) {
    if (textObjects[i].name == SearchName) {
        textObjects[i].name = SearchName + count;
        count++;
    }
}

Error in in your versions:
1. Round bracket missing in if statement

2. You are using the getByName on each textFrame like textFrame[i], instead it should be textFrames.getByNamewithout i.

 

Best regards

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 ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

Another version of script using with the getByName

#target illustrator

var SearchName = "Text";
var count = 0;
var textObjects = app.activeDocument.textFrames
for (var i = 0; i < textObjects.length; i++) {
    try {
        if (textObjects.getByName(SearchName)) {
            textObjects[i].name = SearchName + count;
            count++;
        }
    } catch (e) { }
}
Best regards

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
Engaged ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

LATEST

Working great, thank you!

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