Skip to main content
Participant
November 29, 2022
Answered

How to rename objects using a script

  • November 29, 2022
  • 1 reply
  • 948 views

I have very little programming knowlege, but I'm trying to make a script that will rename selected objects (paths, shapes, etc). For example, I want to name all the objects selected "vinyl."

This is the code I've been trying and can't get to work:

 

var docRef = activeDocument;

var sel = docRef.selection;

for (var i=0; i < sel.length; i++)

     sel.name = "vinyl";

 

I'm using Visual Studio Code with Extendscript and Extendscript Debugger. I've tried saving as a .js and .jsx file. When I run debugging, it doesn't give me any errors, but it also doesn't rename the objects.  What am I doing wrong?

This topic has been closed for replies.
Correct answer Manan Joshi

Change your name assigning line to the following and then try

sel[i].name = "vinyl"

-Manan

1 reply

Manan JoshiCommunity ExpertCorrect answer
Community Expert
November 29, 2022

Change your name assigning line to the following and then try

sel[i].name = "vinyl"

-Manan

-Manan
Participant
November 29, 2022

That worked! Thank you!