Created
August 11, 2024 07:05
-
-
Save UskeS/4f77cf454cdf7910b88f8ad3bf6b939e to your computer and use it in GitHub Desktop.
[Illustrator] Add prefix numbers to layers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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