-
AE script to duplicate and rename.
Hey guys,
Im trying to create my first script for AE.
I have a comp called ‘1234_client_project_name_mon’… i want to have a script that duplicates it 6 times and replaces ‘mon’ with tue, wed, thu etc so i end up with 7 identical comps called.
1234_client_project_name_mon, 1234_client_project_name_tue, 1234_client_project_name_wed etc.here what i have so far:
var day = [“MON”,”TUE”,”WED”,”THU”,”FRI”,”SAT”,”SUN”];
var active = app.project.activeItem; // defines ‘active’ as the active comp
var compname = active.name; // defines ‘compname’ as the name of the active comp
var namearray = compname.split(“_”); // defines ‘namearray’ as array of strings between the underscores.
var suffix = namearray[namearray.length-1]; // defines ‘suffix’ as the string after the last underscore
var prefix = compname.replace (new RegExp (suffix, “g”),””); //defines ‘prefix’ as the comp name minus the string after last underscore.
var activeRoot = app.project.activeItem.parentFolder;for (var i=1; i<=6; i++) {
var newname = (prefix+day[i]);
active.duplicate();
active.name=newname;
}this seems to kind of work, but i end up with all the comp names ending in ‘2’ except for the original active item which has been renamed to ‘…_SUN’ (without 2)
Am i going about it the complete wrong way?
Thanks
Tom