Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function addLeadingZeros (n, length){
var str = (n > 0 ? n : -n) + "";
var zeros = "";
for (var i = length - str.length; i > 0; i--)
zeros += "0";
zeros += str;
return n >= 0 ? zeros : "-" + zeros;
}
var docRef = activeDocument;
var sel = docRef.selection;
for (var i=0; i < sel.length; i++){
sel[i].name = "obj_" + addLeadingZeros(i, 4);
};
app.redraw();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.