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

Search text in a layer

Community Beginner ,
May 04, 2016 May 04, 2016

Copy link to clipboard

Copied

Hi all,

I'm building a script for CS6, and one of the steps is to find a layer that contains text. Inside this text I need to search for specific words. Is there a way to accomplish this?

Thank you for your help.

TOPICS
Scripting

Views

891

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 , May 04, 2016 May 04, 2016

this should point you in the right direction

var search = "dogs";

var layer;

var doc = app.activeDocument;

var text = doc.textFrames;

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

    var position = text.contents.indexOf(search);

    if(position != -1){

        //found search term in text frame

        text.selected = true;

        layer = text.layer.name; //note: this only holds the record of the last layer that contains the search terms

    }

}

Votes

Translate

Translate
Adobe
Guide ,
May 04, 2016 May 04, 2016

Copy link to clipboard

Copied

this should point you in the right direction

var search = "dogs";

var layer;

var doc = app.activeDocument;

var text = doc.textFrames;

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

    var position = text.contents.indexOf(search);

    if(position != -1){

        //found search term in text frame

        text.selected = true;

        layer = text.layer.name; //note: this only holds the record of the last layer that contains the search terms

    }

}

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 ,
May 05, 2016 May 05, 2016

Copy link to clipboard

Copied

Thanks a lot Qwertyfly!

This is a great help

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 ,
Nov 13, 2017 Nov 13, 2017

Copy link to clipboard

Copied

LATEST

Hello,

I need to use a script like this also,

I need to be able to text search for all the sub layers named: "circle" in my illustrator file,

and then make them into a separate isolated layer of all the circles only.

Can you help me with a correct script?

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
Guide ,
May 05, 2016 May 05, 2016

Copy link to clipboard

Copied

Glad I could help you out, good luck with your scripting.

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