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.
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
}
}
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
}
}
Copy link to clipboard
Copied
Thanks a lot Qwertyfly!
This is a great help
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Glad I could help you out, good luck with your scripting.