ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Import video into comps script

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Matt Volp
Import video into comps script
on Sep 11, 2017 at 12:06:54 pm
Last Edited By Matt Volp on Sep 11, 2017 at 1:12:38 pm

Hi all,

Let's say we have three comps in the project panel, named "Lorem", "Ipsum" and "Dolor".

Let's also say we have three video files (.movs) imported into the project panel named "Lorem", "Ipsum" and "Dolor".

I want to run a script which will add the video file named "Lorem" to the comp named "Lorem", the the video file named "Ipsum" to the comp named "Ipsum" and the video file named "Dolor" to the comp named "Dolor".

It's important to note that the comps will already have been made, they are just lacking the relevant video files.

There could be three files like in this example or there could be hundreds.

So far I have this:

var myProject = app.project;

for (var i = 1; i <= myProject.numItems; i++){
if (myProject.item(i) instanceof CompItem){
var myComp = myProject.item(i);
}
if (myProject.item(i) instanceof FootageItem){
var myFootage = myProject.item(i);
}
if (myComp.name == myFootage.name){
myComp.layers.add(myFootage);
}
}

It works, but is it what you guys would do?


Return to posts index

Dan Ebberts
Re: Import video into comps script
on Sep 11, 2017 at 1:26:28 pm

Something like this maybe:


function findComp(theName){
for (var i = 1; i <= app.project.numItems; i++){
if ((app.project.item(i) instanceof CompItem) && (app.project.item(i).name == theName)){
return app.project.item(i);
}
}
return null;
}

var myItem;
var myComp;
for (var i = 1; i <= app.project.numItems; i++){
myItem = app.project.item(i);
if ((myItem instanceof FootageItem) && (myItem.name.toLowerCase().substr(-4) == ".mov")){
myComp = findComp(myItem.name.substr(0,myItem.name.length-4));
if (! (myComp == null)){
myComp.layers.add(myItem);
}
}
}



Dan



Return to posts index

Matt Volp
Re: Import video into comps script
on Sep 11, 2017 at 1:47:37 pm

I thought it would include a function.

I've learned a lot there, Dan.

Thanks!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]