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

Replacing text contents via script

Explorer ,
Feb 28, 2019 Feb 28, 2019

Copy link to clipboard

Copied

Hi everyone,

I want to replace the word "PANTONE " with "P." in all text objects in the document.

i've managed to take content from one textFrame and replace it just like i want, but it works only in JS console

function test(){

var doc =app.activeDocument;

   var t = doc.textFrames.getByName("usedcolor5").contents.replace("PANTONE ", "P.");

    return t;

};

test();

my file looks something like this:

TOPICS
Scripting

Views

10.8K

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

Explorer , Mar 01, 2019 Mar 01, 2019

Thanks it actually helped

Here is my code:

#target illustrator

function test() {

    var doc = app.activeDocument;

    var myArray = ["usedcolor1", "usedcolor2", "usedcolor3", "usedcolor4", "usedcolor5", "usedcolor6", "usedcolor7", "usedcolor8", "usedcolor9"];

    for (var i = 0; i < myArray.length; i++) {

                var t = doc.textFrames.getByName(myArray);

        var txt = t.contents.replace("PANTONE ", "P.");

        t.contents = txt;

    }

};

test();

Votes

Translate

Translate
Adobe
Community Expert ,
Feb 28, 2019 Feb 28, 2019

Copy link to clipboard

Copied

For the beginning:

Find and Replace Script for multiple files

Have fun

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
Explorer ,
Mar 01, 2019 Mar 01, 2019

Copy link to clipboard

Copied

LATEST

Thanks it actually helped

Here is my code:

#target illustrator

function test() {

    var doc = app.activeDocument;

    var myArray = ["usedcolor1", "usedcolor2", "usedcolor3", "usedcolor4", "usedcolor5", "usedcolor6", "usedcolor7", "usedcolor8", "usedcolor9"];

    for (var i = 0; i < myArray.length; i++) {

                var t = doc.textFrames.getByName(myArray);

        var txt = t.contents.replace("PANTONE ", "P.");

        t.contents = txt;

    }

};

test();

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