Skip to content

Instantly share code, notes, and snippets.

@p2or
Created March 30, 2017 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p2or/e61a42118e98a5661391ca2ab0cc68c0 to your computer and use it in GitHub Desktop.
Save p2or/e61a42118e98a5661391ca2ab0cc68c0 to your computer and use it in GitHub Desktop.
Rename Selection #Illustrator
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