FORUMS: list search recent posts

[ExtendScript] Get the index of a new item

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Charlie Leroy
[ExtendScript] Get the index of a new item
on Oct 23, 2014 at 7:47:12 pm

Hello guys,

I have been looking for some time a way to get the index of an item if I know its name.

In my scene I have one main comp and several subcomp
What I want to do is:

Duplcate all the comp and once that is done, replace the old subcomp by the new one.

But I did not find a way to retrieve the index for the created subcomps.
I have to use :
but dont know how to find x for the created comps.

Maybe there is another way of doing, using ID or Name insted of the item index but I can not find it.

any idea of how to do that?


Return to posts index

Ryan McAdam
Re: [ExtendScript] Get the index of a new item
on Mar 15, 2016 at 3:38:29 pm

I realize this answer is a bit late but here is a function written to find the index of an item among the items collection by name. In other words it will find and return the index of an item from among all the other items in your project panel. Not sure if this is what you were looking for. Hope it helps.

// Find the index of an item in the items collection by name
function findItemIndexByName(searchName)
var projLength = app.project.items.length;
var index = null;

for (var i = 1; i <= projLength; i++)
var nameProperty = app.project.item(i).name;
if ( nameProperty == searchName)
index = i;
return index;

Return to posts index

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