Copy link to clipboard
Copied
Hi,
I have a need to rename selected paths with script. Specifically, I have a path (named or without name) that I need to rename adding the suffix "+score" to the end. So, if it is named "object", the script would rename it to "object+score". I want to be able to select the objects I need to rename and then run the script to only changed the selected objects/paths.
After reading a bunch of past posts, I have been trying for hours without success. This was similar to a sample script I tried and not error, but nothing happens. Any help would be appreciated.
#target Illustrator
var doc = activeDocument;
var sel = doc.selection;
var suffix="+score";
for (var i=0; i < sel.length; i++)
sel.name = sel.name + suffix;
I am not a scripter. I just piece together scripts until I can get them to work for me. Thanks in advance!
You forgot the counter:
{sel[i].name = sel[i].name + suffix;}
One problem remains, however: an unnamed item only has a placeholder name. The name itself is blank. An option would be:
{sel[i].name = (sel[i].name == "") ? sel[i].typename+suffix : sel[i].name+suffix;}
Copy link to clipboard
Copied
You forgot the counter:
{sel[i].name = sel[i].name + suffix;}
One problem remains, however: an unnamed item only has a placeholder name. The name itself is blank. An option would be:
{sel[i].name = (sel[i].name == "") ? sel[i].typename+suffix : sel[i].name+suffix;}
Copy link to clipboard
Copied
@pixxxelschubser, thank you so much! You have no idea.
Actually, I added the counter and that worked. It is working thus far with named and unnamed items with placeholder names. I will continue testing.