How do I reference footage by name?

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
swink85
Posts: 13
Joined: January 5th, 2010, 1:37 am

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?
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

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.
herbie
Posts: 13
Joined: March 16th, 2010, 5:37 pm

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
swink85
Posts: 13
Joined: January 5th, 2010, 1:37 am

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.
Post Reply