Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Import video into comps script

  • Import video into comps script

    Posted by Matt Volp on September 11, 2017 at 12:06 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?

    Matt Volp replied 8 years, 7 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    September 11, 2017 at 1:26 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

  • Matt Volp

    September 11, 2017 at 1:47 pm

    I thought it would include a function.

    I’ve learned a lot there, Dan.

    Thanks!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy