Skip to content

Instantly share code, notes, and snippets.

@amitkhare
Last active June 19, 2022 13:34
Show Gist options
  • Save amitkhare/e6c8ecbffb08034d35f99b42c8bf7f66 to your computer and use it in GitHub Desktop.
Save amitkhare/e6c8ecbffb08034d35f99b42c8bf7f66 to your computer and use it in GitHub Desktop.
Adobe Illustrator path batch rename
#target illustrator
var docRef = app.activeDocument;
with (docRef) {
//int j = items.pathItems[0];
// layers[0].name = "Layer 1";
alert(app.activeDocument.pathItems[0].name + "");
for(var i =0; i < app.activeDocument.pathItems.length; i++) {
app.activeDocument.pathItems[i].name = pad((i+1), 3);
}
}
// pad with 0 number
/*
pad(10, 4); // 0010
pad(9, 4); // 0009
pad(123, 4); // 0123
pad(10, 4, '-'); // --10
*/
function pad(n, width, z) {
z = z || '0';
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment