-
Importing unique files only
Hey guys. I’ve been struggling with this one for days. I’m getting all imported file’s paths, storing then in a array and (trying) to only import any new files that are not in the project. Except it reimports all files everytime and not the unique ones. I’m yet to filter for folders and all that, but I’m sure they are all valid files. Probably missing a simple detail…
for (var i = 0; i < myUniqueFolders.length; i++){function ImportUniqueFiles(){
var folder = new Folder;
folder = Folder(myUniqueFolders[i]);var files = folder.getFiles();
var myImportedFiles = [];
for (var k = 1; k <= myProj.numItems; k++) {
var thisFile = app.project.item(k).file;
myImportedFiles.push(thisFile);
alert(myImportedFiles.length);
}importFiles(files);
function importFiles(files) {
for(var j = 0; j < files.length; j++) {
if(myImportedFiles.indexOf(files[j]) == -1){
alert(files[j]);
app.project.importFile(new ImportOptions(files[j]));
}else{
alert("not unique");
}
}
}
}}