Multiple textFrames with same name, always select only the last one.
Hello!
In my files, sometimes i have multiple textFrames with the same layer name("Layername").
Is it possible for a script to always select only the last one( in the array of "Layernames") in the document?
I put together something, but the following script selects all of the textFrames with the same name. I think i have to add another loop, which adds .length -1 to get only the last "Layername" object from the array of "Layernames" but i am not sure where should i put it. all my attempts have resulted in null.
var doc = app.activeDocument;
doc.selection = null; //ensure there is nothing in the document selected already. this way you only get the selection you want.
for(var a=0;a<doc.textFrames.length;a++){
if (doc.textFrames[a].name == "Layername"){
doc.textFrames[a].selected = true;
}
}just for reference, incase i am getting the index of layers wrong. I always want to change only the last one, marked in blue on the picture.

