forked from ff6347/after-effects-script-snippets
-
Notifications
You must be signed in to change notification settings - Fork 4
/
rename-layers.jsx
39 lines (36 loc) · 1021 Bytes
/
rename-layers.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* @author fabiantheblind
* @description rename selected layers with number
* this happens in comp and project panel
*
*
* @todo catch error if layer as no source
*/
fun();
function fun(){
app.beginUndoGroup("rename layers");
var curComp = app.project.activeItem;
if (!curComp || !(curComp instanceof CompItem)){
alert("noComp");
return;
}
var promttxt = "layer";
if(curComp.selectedLayers.length < 1){
alert("no selection");
return;
}else{
promttxt = curComp.selectedLayers[0].name;
}
var basename = prompt("enter base name will have a number",promttxt);
if(basename.length < 1){
alert("nothing is to short");
return;
}
for(var i =0; i < curComp.selectedLayers.length;i++){
var name = basename + " " + String(i+1);
var currLayer = curComp.selectedLayers[i];
try{currLayer.source.name = name;}catch(error){ $.writeln( "this layer has no source"); }
currLayer.name = name;
}
app.endUndoGroup();
}