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

Select all text layers with the same name

Explorer ,
Jun 28, 2023 Jun 28, 2023

Copy link to clipboard

Copied

Hello dear Illustrator users,

 

I have a document containing 10 iterations of the same object. With identical naming for all the sublayers of each objects:

 

illustrator_scripting.jpg

 

I need to replace the "space" between aaaa and bbbb by a line break for all 10 iterations ("bbbb" has to be a on a second line) on all 10 iterations.

 

I found a script on the Illustrator community that is working pretty well, but unfortunately only on the selected layer:

 

var text = app.activeDocument.selection[0];
var string = text.contents;
string = string.replace(/ /g,"\n");
text.contents= string;

 

I need the same thing but applied on all the layers with the name "TOTO" in this document (10 layers).

 

Thank you for your help.

TOPICS
Scripting

Views

417
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 , Jun 28, 2023 Jun 28, 2023
var text = app.activeDocument.textFrames;
for (var i = 0; i < text.length; i++) {
    if (text[i].name == "TOTO") {
        var string = text[i].contents;
        string = string.replace(/ /g,"\n");
        text[i].contents= string;
    }
}

Votes

Translate
Adobe
Guide ,
Jun 28, 2023 Jun 28, 2023

Copy link to clipboard

Copied

var text = app.activeDocument.textFrames;
for (var i = 0; i < text.length; i++) {
    if (text[i].name == "TOTO") {
        var string = text[i].contents;
        string = string.replace(/ /g,"\n");
        text[i].contents= string;
    }
}

Votes

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
Explorer ,
Jun 28, 2023 Jun 28, 2023

Copy link to clipboard

Copied

LATEST

That is working perfectly! Thank you so much for your help.

Votes

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