Created
October 17, 2024 01:02
-
-
Save UskeS/e1b72f3c72bb32c77b772fd540c8d150 to your computer and use it in GitHub Desktop.
[Illustrator] Add sequential numbers to the beginning of all 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
/** | |
* @fileoverview すべてのレイヤーの先頭に連番を追加する | |
* @version v1.0.0 | |
* @author Yusuke SAEGUSA | |
* @description | |
* 元ネタ:https://community.adobe.com/t5/illustrator%E3%83%95%E3%82%A9%E3%83%BC%E3%83%A9%E3%83%A0-discussions/illustrator-%E3%83%AC%E3%82%A4%E3%83%A4%E3%83%BC%E5%90%8D%E3%81%AE%E3%83%AA%E3%83%8D%E3%83%BC%E3%83%A0%E3%81%AE%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E6%8E%A2%E3%81%97%E3%81%A6%E3%81%84%E3%81%BE%E3%81%99-after-effects%E8%AA%AD%E3%81%BF%E8%BE%BC%E3%81%BF%E7%94%A8/m-p/14793060?profile.language=ja#M37254 | |
*/ | |
(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