Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Adding label to specific item EXTENDSCRIPT

  • Adding label to specific item EXTENDSCRIPT

    Posted by Rainier Raydán on May 10, 2017 at 8:53 pm

    Hi!

    I`m working in a project at the office and we want to write a script that creates folders. I’ve already did that with this simple code:

    app.project.items.addFolder("RENDER");
    app.project.items.addFolder("FOOTAGE");
    app.project.items.addFolder("MATERIALES");
    app.project.items.addFolder("PRECOMPS");

    Then we want to add labels to an specific folder, in this case is the “RENDER” folder. It suppose to change to red and the other stay in yellow.

    I’ve try this:

    app.project.items.addFolder("RENDER");
    app.project.items.addFolder("FOOTAGE");
    app.project.items.addFolder("MATERIALES");
    app.project.items.addFolder("PRECOMPS");
    app.project.item(4).label= (1)

    But I dont want to guess the index of the item, I just want the RENDER folder to turns red. There’s a way to add labels to an item named RENDER?

    THANKS!

    Rainier Raydán replied 9 years ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    May 10, 2017 at 9:36 pm

    The simplest would probably be to save the Render folder in a variable:

    var renderFolder = app.project.items.addFolder(“RENDER”);
    app.project.items.addFolder(“FOOTAGE”);
    app.project.items.addFolder(“MATERIALES”);
    app.project.items.addFolder(“PRECOMPS”);
    renderFolder.label= 1;

    Alternatively, you could loop through the project items until you find a FolderItem named “RENDER”.

    Dan

  • Rainier Raydán

    May 10, 2017 at 9:37 pm

    I think I solve it with this :

    app.project.items.addFolder("# RENDER comps");
    app.project.items.addFolder("FOOTAGE");
    app.project.items.addFolder("MATERIALES");
    app.project.items.addFolder("PRECOMPS");
    app.project.items.addFolder("Solids");

    var i = 1;

    while (i<= app.project.items.length){

    var itemX = app.project.item(i);

    i = i + 1;
    if (itemX.name == "# RENDER comps"){

    itemX.label = (1);
    }
    }

    But know I want to add a line that ignores “Solids” folder if the folder already exist.

    Can anybody help me?

  • Dan Ebberts

    May 10, 2017 at 9:54 pm

    Something like this:


    var foundIt = false;
    for (var i = 1; i <= app.project.items.length; i++){
    if (app.project.item(i) instanceof FolderItem && app.project.item(i).name == "Solids"){
    foundIt = true;
    break;
    }
    }
    if (! foundIt){
    app.project.items.addFolder("Solids");
    }

    Dan

  • Rainier Raydán

    May 11, 2017 at 1:28 pm

    Thanks! Works just fine.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy