AE Script: Function to directly refer to a Project Item by Name
Interested in a landing page video for your business? Contact us today!
Selected portfolio work samples:
The AE function written to refer to a Project Item by Name
I wrote this function to allow you to directly refer to a Project item by it’s name (assuming you know the name). This way you do not have to use the index number for the item, something I didn’t like when writing scripts:
function projectItem(name) { var items = app.project.items; i = 1; while (i <= items.length) { if (items[i].name == name) { return app.project.item(i); break; } i++; } }
And here is an example of using it. Assuming there is a folder named ‘folder’ in the Project Window:
newComp = projectItem("folder").items.addComp("Lower-Level Comp", 640, 480, 1.0, 5.0, 25.0);