Quantcast
Channel: Adobe Community : Unanswered Discussions - After Effects
Viewing all articles
Browse latest Browse all 30854

Can't get a comparison between a folder name and a string to work

$
0
0

Dear community,

 

I have a really simple ExtendScript-example that I just can't get to work and I have no idea what could be wrong. I'm trying to write a script that goes through all the items in the project panel and stores references to all the folders which names are like "layer1", "layer2", and so on, in an array. This is the code that should alert 3 times in my case, but it doesn't alert once..

 

for (var i=1; i<=app.project.numItems; i++)

{

    if ((app.project.item(i) instanceof FolderItem) && (app.project.item(i).name == "layer"+i))

    { 

        alert("found folder = " + app.project.item(i).name);

    }

}

 

Inside the project in the root-directory there are 2 comps and 3 folders named 'layer1', 'layer2' and 'layer3' - so I should see 3 alerts when executing the above script. For testing-purposes I changed the second part of the if-statement to a 'static' value like so:

.. && (app.project.item(i).name == "layer1"))  --> then it works! But I need a dynamic solution..

 

Thanks very much for ANY help in advance!

 

Greetings,

Gilbert


Viewing all articles
Browse latest Browse all 30854

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>