I found a script on here that adds percentage symbols to numbers in illustrator. It works great and I figured out way to auto populate the fields with the needed strings to run the code without having to remember what to fill in. However, you still need to hit enter three times to get it to run. Not a huge deal. But, I am using this script to create dozens of graphs per day, and it is kind of annoying. It would be much easier if I could just have the script run without the need for the prompts. Can somebody please help me out with this? Thank you in advance!
Here is the script:
var scope = app.activeDocument.selection.length ? app.activeDocument.selection : app.activeDocument.pageItems;
var find = prompt("Find: (Text or GREP/regex)","(\\d+\\,?\\d*\\.?\\d*)");
if (find !== null) {
var replace = prompt("Replace: (Text or GREP/regex)","$1%");
if (replace !== null) {
var changes = 0;
for (var i = 0; i < scope.length; i++) {
var text = scope[i];
var string = text.contents;
if (typeof string == "string") {
var newstring = string.replace(new RegExp(find, 'g'), replace);
if (newstring != string) {
changes++;
var paragraphsArray = newstring.split("\n");
text.paragraphs.removeAll();
for (var ii = 0; ii < paragraphsArray.length; ii++) {
text.paragraphs.add(paragraphsArray[ii]);
}
}
}
}
alert(changes == 1 ? "1 text object changed" : changes + " text objects changed");
}
}