Skip to content

Instantly share code, notes, and snippets.

@UskeS
Created August 11, 2024 07:05
Show Gist options
  • Save UskeS/4f77cf454cdf7910b88f8ad3bf6b939e to your computer and use it in GitHub Desktop.
Save UskeS/4f77cf454cdf7910b88f8ad3bf6b939e to your computer and use it in GitHub Desktop.
[Illustrator] Add prefix numbers to layers.
(function () {
if (app.documents.length === 0) {
alert("ドキュメントが開かれていません。ドキュメントを開いてから実行してください。");
return;
}
var lay = app.activeDocument.layers;
for (var i = 0; i < lay.length; i++) {
lay[i].name = ("0" + (i + 1)).slice(-2) + "_" + deletePrefix(lay[i].name);
}
})();
alert("終了しました。");
// 先頭の数字2桁+アンダーバーを削除する関数
function deletePrefix(str) {
if (/^[0-9]{2}_/.test(str)) {
str = str.replace(/^[0-9]{2}_/, "");
}
return str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment