Page 1 of 1

How do I reference footage by name?

Posted: August 29th, 2011, 10:58 pm
by swink85
I am looking to import footage into a comp. I know the standard way of doing this is to reference the footage by its index number, but I am in a situation where that number will change depending on the file name.

Example:

I want to import cats.mov into comp but do not know ahead of time what that footage's index number will be. How do I reference cats.mov by name so that I can import it into the comp?

Also, how do I have the script add the footage to the comp at the beginning of that comp's work area?

Re: How do I reference footage by name?

Posted: August 30th, 2011, 1:08 am
by Paul Tuersley
You'll have to loop through app.project.items looking for one with the name "cats.mov".
Use comp.layers.add() to add the layer to the comp, then set layer.startTime to comp.workAreaStart.

I haven't bothered to write the code for you but you should be able to work it out from this.

Re: How do I reference footage by name?

Posted: August 30th, 2011, 1:29 am
by herbie
You can do a 'for' loop matching the name of 'cats.mov'
ex.

Code: Select all

for (i = 1; i <= app.project.items.length; i++) {
    if ((app.project.item(i).name == "cat.mov") && (app.project.item(i).typeName == "Footage")) {
        //do stuff
        }
    }
The second part of your question about adding the footage to the comp's work area..
ex.
You have a variable for your current comp variable named myComp..

Code: Select all

myComp.layers.add(newFootage);
myComp.layer(1).startTime = myComp.workAreaStart;
I hope this helps.

Cheers

Re: How do I reference footage by name?

Posted: August 30th, 2011, 8:35 am
by swink85
Thanks for the quick answers, guys! The first question was one that had been nagging me for forever, but I never got around to posting it. Seems obvious now.