Copy link to clipboard
Copied
I am not sure how to utilize the index method of the textFrames collection.
I am trying to search through all of my text frames to see if it contains: "SW"
If it does contain "SW" I want to have it remove "SW" from it's current location in the textFrame and put this at the beginning of the textFrame: "Switch - "
Here is an example of a textFrame: PARK_BRAKE_SW
Here is an example of a textFrame after the script would run: SWITCH - PARK_BRAKE
Could also look like this: SW_DISCONNECT_c0
Which after the script would look like this: SWITCH -_DISCONNECT_c0
Any help or thoughts on this would be appreciated!
Hi subieguy2,
SW always follows an underscore or is behind of one?
SW is always in capitals?
This could be a workaround (but it is a little bit like the flying words "a shot from behind through the chest in the eye")
...var theTF = app.activeDocument.textFrames;
var TF_len = theTF.length;
var aCon;
for (i = 0; i <TF_len; i++) {
aCon = theTF.contents;
if (aCon.match(/_SW|SW_/) != null) {
aCon = aCon.replace(/_SW|SW_/,"");
aCon = "SWITCH_" +aCon;
theTF.contents = aCon;
Copy link to clipboard
Copied
Hi subieguy2,
SW always follows an underscore or is behind of one?
SW is always in capitals?
This could be a workaround (but it is a little bit like the flying words "a shot from behind through the chest in the eye")
var theTF = app.activeDocument.textFrames;
var TF_len = theTF.length;
var aCon;
for (i = 0; i <TF_len; i++) {
aCon = theTF.contents;
if (aCon.match(/_SW|SW_/) != null) {
aCon = aCon.replace(/_SW|SW_/,"");
aCon = "SWITCH_" +aCon;
theTF.contents = aCon;
}
}
Perhaps someone else knows a better way.
Have fun
Copy link to clipboard
Copied
That is EXACTLY what I was looking for! Thanks so much!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now