// rename unlocked layers with prefix /* by ying v0.1: (2021.07.27) * build */ #target "Illustrator"; // 1. lock other first total_all = app.activeDocument.layers.length; alert(total_all); // top layers // 2. get unlock layer list highlight_list = []; for (i = 0; i < total_all; i++) { if (app.activeDocument.layers[i].locked == false) highlight_list.push(app.activeDocument.layers[i]); } total = highlight_list.length; alert(total); // 3. get prefix name var newName = prompt('What is the prefix? -- Shining Camera', 'New Prefix'); if (newName) { // 4. rename action for (i = 0; i < total; i++) { t_layer = highlight_list[i]; t_layer.name = newName+'_'+i; } // 5. unlock all after done total_all = app.activeDocument.layers.length; for (i = 0; i < total_all; i++) { if (app.activeDocument.layers[i].locked == true) app.activeDocument.layers[i].locked = false; } }