Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Find item and parent it to a specific folder

  • Find item and parent it to a specific folder

    Posted by Rainier Raydán on May 11, 2017 at 8:38 pm

    Hello again!

    I´m trying to find some items in my project so they can be re organized in specific folders.

    I have this:

    function foundFootage(){
    var i = 1; i <= app.project.items.length; i++;
    if (app.project.item(i).name = "Comp 2"){
    app.project.item(i).parentFolder = app.project.item(folderFound);
    }
    var folderFound = 1; folderFound <= app.project.items.length; folderFound++;
    if (app.project.item(folderFound).name = "FOOTAGE"){
    foundFootage();
    }
    }

    The idea is to find the folder and then call the function who search the item and parent it to this folder.

    anyway, it’s not working so… can anybody help me?

    Dan Ebberts replied 9 years ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    May 11, 2017 at 10:33 pm

    Play around with this:


    function main(){
    function findFolder(theName){
    for (var i = 1; i <= app.project.numItems; i++){
    if (app.project.item(i) instanceof FolderItem && app.project.item(i).name == theName){
    return app.project.item(i);
    }
    }
    return null;
    }

    function findComp(theName){
    for (var i = 1; i <= app.project.numItems; i++){
    if (app.project.item(i) instanceof CompItem && app.project.item(i).name == theName){
    return app.project.item(i);
    }
    }
    return null;
    }

    var myFolder = findFolder("FOOTAGE");
    if (myFolder == null){
    alert("Can't find folder 'FOOTAGE'");
    return;
    }
    var myComp = findComp("Comp 2");
    if (myComp == null){
    alert("Can't find comp 'Comp 2'");
    return;
    }
    myComp.parentFolder = myFolder;
    }
    main();

    Dan

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