Item object

app.project.item(index)
app.project.items[index]

Description

The Item object represents an item that can appear in the Project panel.
The first item is at index 1.

• Item is the base class for AVItem and for FolderItem, which are in turn the base classes for various other item types, so Item attributes and methods are available when working with all of these item types. See AVItem object” and “FolderItem object”.

Attributes

Attributes Reference Description
name “Item name attribute” The name of the object as shown in the Project panel.
comment “Item comment attribute” A descriptive string.
id “Item id attribute” A unique identifier for this item.
parentFolder “Item parentFolder attribute” The parent folder of this item.
selected “Item selected attribute” When true, this item is currently selected.
typeName “Item typeName attribute” The type of item.
label “Item label attribute” The label color for the item.

Methods

Method Reference Description
remove() “Item remove() method” Deletes the item from the project.

Example

This example gets the second item from the project and checks that it is a folder. It then removes from the folder any top-level item that is not currently selected. It also checks to make sure that, for each item in the folder, the parent is properly set to the correct folder.
var myFolder = app.project.item(2);
if (myFolder.typeName != "Folder") {
alert("error: second item is not a folder");
}
else {
var numInFolder = myFolder.numItems;
// Always run loops backwards when deleting things:
for(i = numInFolder; i >= 1; i--) {
var curItem = myFolder.item(i);
if ( curItem.parentFolder != myFolder) {
alert("error within AE: the parentFolder is not set correctly");
}
else {
if ( !curItem.selected && curItem.typeName == "Footage") {
//found an unselected solid.
curItem.remove();
}
}
}
}

Other Tags

Posted in Item object and tagged , , , , , , , , , , , , , , , , , , , .