FORUMS: list search recent posts

AE script to duplicate and rename.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Tom Holmes
AE script to duplicate and rename.
on Oct 12, 2015 at 11:28:23 am

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 =; // 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]);

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?



Return to posts index

Dan Ebberts
Re: AE script to duplicate and rename.
on Oct 12, 2015 at 4:19:29 pm

I think I'd do it like this:

var days = ["tue","wed","thu","fri","sat","sun"];
var myComp = app.project.activeItem;
var myName =;
var newComp;

for (var i = 0; i < days.length; i++){
newComp = myComp.duplicate(); = myName.substr(0,myName.length-3) + days[i];


Return to posts index

Tom Holmes
Re: AE script to duplicate and rename.
on Oct 12, 2015 at 4:25:49 pm

Thank very much Dan! right as always :)


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved