ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Some insight in finding and placing specific items in a specific folder

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Marc Konings
Some insight in finding and placing specific items in a specific folder
on Dec 8, 2017 at 2:50:08 pm

Hello Community,

I have tried to find a script ( or parts of scripts) where I can find items, using only a part of the name / a specific word inside that item.
So that later on I can place that selected file inside a specific folder.

Could you help me out?

In this particular case, I would like to find a solution in code to select all layers with "Alpha", "ALPHA" and "alpha" somewhere in it's name, and arrange it in the folder named "06_COMPS".






If you guys know a work around this code or you have a solution, please tell me,
the try-outs (cut and pasting parts of codes I found on the net from different sources) have been only confusing me even more.


Much appreciated,

Marc




// the closest I could get to this non working script:

function main(){





var myProject = app.project.items;

var nom= app.project.item(1).name



var SelectItem = app.project.activeItem

var nameItem = app.project.activeItem.name



var theName



function findFolder(theName){

for (var i = 1; i &lt;= app.project.numItems; i++){

if (app.project.item(i) instanceof FolderItem && app.project.item(i).name == theName){

return app.project.item(i);

}

}

return null;

}

var folderItem = findFolder("06_COMPS");

if (folderItem == null){

return;

}





var myItemFolder = findFolder(nameItem + "Alpha");

if (myItemFolder == null){

return;

}



myItemFolder.parentFolder = folderItem;

SelectItem.parentFolder = folderItem



}



main()


Return to posts index

Dan Ebberts
Re: Some insight in finding and placing specific items in a specific folder
on Dec 8, 2017 at 9:08:41 pm

Try this:


function main(){
function getFolder(theName){
for (var i = 1; i <= app.project.numItems; i++){
if (app.project.item(i).name == theName && app.project.item(i) instanceof FolderItem){
return app.project.item(i);
}
}
return null;
}
var compFolder = getFolder("06_COMPS");
if (compFolder == null){
alert("Can't find folder '06_COMPS'");
return;
}
var alphaComps = [];
for (var i = 1; i <= app.project.numItems; i++){
if (app.project.item(i) instanceof CompItem){
if (app.project.item(i).name.toLowerCase().indexOf("alpha") > -1){
alphaComps.push(app.project.item(i));
}
}
}
for (var i = 0; i < alphaComps.length; i++){
alphaComps[i].parentFolder = compFolder;
}
}
main();


Dan



Return to posts index

Marc Konings
Re: Some insight in finding and placing specific items in a specific folder
on Dec 9, 2017 at 11:14:20 am

Thank you so much mister Ebberts!

This works like a charm!
I do see how the code structure is logic now!

Thank you!

Marc


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]