Item object

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.

Syntax

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

Attribute List

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

Methods

Method Reference Description
remove() “Item remove() method” on page 80 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();
            }
        }
    }
}

comment attribute

app.project.item(index).comment

Description: A string that holds a comment, up to 15,999 bytes in length after any encoding conversion. The comment is for the user's purpose only; it has no effect on the item's appearance or behavior.

Type: String read/write


id attribute

app.project.item(index).id

A unique and persistent identification number used internally to identify an item between sessions. The value of the ID remains the same when the project is saved to a file and later reloaded. However, when you import this project into another project, new IDs are assigned to all items in the imported project. The ID is not displayed anywhere in the user interface.

Type: Integer read-only


label attribute

app.project.item(index).label

The label color for the item. Colors are represented by their number (0 for None, or 1 to 16 for one of the preset colors in the Labels preferences). Custom label colors cannot be set programmatically.

Type: Integer (0 to 16) read/write


name attribute

app.project.item(index).name

The name of the item as displayed in the Project panel.

Type: String read/write


parentFolder attribute

app.project.item(index).parentFolder

The FolderItem object for the folder that contains this item. If this item is at the top level of the project, this is the project's root folder (app.project.rootFolder). You can use the ItemCollection’s addFolder method to add a new folder, and set this value to put items in the new folder. See “ItemCollection addFolder() method” on page 82.

Type: FolderItem object read/write

Example:

This script creates a new FolderItem in the Project panel and moves compositions into it.

// create a new FolderItem in project, with name “comps”
var compFolder = app.project.items.addFolder(“comps”);
// move all compositions into new folder by setting
// compItem’s parentFolder to “comps” folder
for(var i = 1; i <= app.project.numItems; i++) {
    if(app.project.item(i) instanceof CompItem)
    app.project.item(i).parentFolder = compFolder;
}

remove() method

app.project.item(index).remove()

Deletes this item from the project and from the Project panel. If the item is a FolderItem, all the items contained in the folder are also removed from the project. No files or folders are removed from disk.

Parameters: None.

Returns: Nothing


selected attribute

app.project.item(index).selected

When true, this item is selected. Multiple items can be selected at the same time. Set to true to select the item programmatically, or to false to deselect it.

Type: Boolean read/write


typeName attribute

app.project.item(index).typeName

A user-readable name for the item type; for example, “Folder”, “Footage”, or “Composition”.

Type: String read-only