Highlighted

how to add the dynamic content of a folder to an existing comp

Explorer ,
Jun 21, 2020

Copy link to clipboard

Copied

Hi,

 

What I want to do it to import the content of a folder to an existing comp. The content of the folder is dynamic and it has only .mov files.

 

I was able to import all the files from the folder into the selected comp but it doesn't want to add more than the first imported file to the selected comp. Any idea what I am doing wrong..?

//find all the files and import them (working)
var sourceFolder = Folder ("C:/.../");
    var files = sourceFolder.getFiles("*.MOV");
    for (var f =0; f < files.length; f ++) {
    app.project.importFile(new ImportOptions(files[f]));

    }
//find the comp (working)
var myFinalComp;// find the comp name "FINAL_COMP"
    for (var i = 1; i <= app.project.numItems; i ++) {
        if ((app.project.item(i) instanceof CompItem) && (app.project.item(i).name === "FINAL_COMP")){
            myFinalComp= app.project.item(i);
            break;
        }
    }
//add all the imported files to the FINAL_COMP (not fully working...just adds only the first imported file to the selected comp instead of adding all the imported files)
var myComp = myFinalComp;
var myFootage = files;
for (var g = 1; g <= myProject.numItems; g++){
myFootage = myProject.item(g);
    if(myFootage.name == footageName && myFootage instanceof FootageItem){
        break;
    }
}
myComp.layers.add(myFootage);

 Thank you very much.

A.

 

Topics

How to, Scripting

Views

65

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

how to add the dynamic content of a folder to an existing comp

Explorer ,
Jun 21, 2020

Copy link to clipboard

Copied

Hi,

 

What I want to do it to import the content of a folder to an existing comp. The content of the folder is dynamic and it has only .mov files.

 

I was able to import all the files from the folder into the selected comp but it doesn't want to add more than the first imported file to the selected comp. Any idea what I am doing wrong..?

//find all the files and import them (working)
var sourceFolder = Folder ("C:/.../");
    var files = sourceFolder.getFiles("*.MOV");
    for (var f =0; f < files.length; f ++) {
    app.project.importFile(new ImportOptions(files[f]));

    }
//find the comp (working)
var myFinalComp;// find the comp name "FINAL_COMP"
    for (var i = 1; i <= app.project.numItems; i ++) {
        if ((app.project.item(i) instanceof CompItem) && (app.project.item(i).name === "FINAL_COMP")){
            myFinalComp= app.project.item(i);
            break;
        }
    }
//add all the imported files to the FINAL_COMP (not fully working...just adds only the first imported file to the selected comp instead of adding all the imported files)
var myComp = myFinalComp;
var myFootage = files;
for (var g = 1; g <= myProject.numItems; g++){
myFootage = myProject.item(g);
    if(myFootage.name == footageName && myFootage instanceof FootageItem){
        break;
    }
}
myComp.layers.add(myFootage);

 Thank you very much.

A.

 

Topics

How to, Scripting

Views

66

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 21, 2020 0
efikrd LATEST
Explorer ,
Jun 21, 2020

Copy link to clipboard

Copied

I figured that I can use the fact that the files already imported are selected/activeItems already so I could use that instead. I think I needed a different approach. If there is another way, please share it.

var selectedFilesComp = app.project.activeItem;

for(var i = 1; i <= app.project.numItems; i++){
    if ((app.project.item(i) instanceof FootageItem) && app.project.item(i).selected){
        selectedFilesComp.layers.add(app.project.item(i));
    }
  }

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 21, 2020 0