3 Replies Latest reply on Apr 5, 2016 10:56 AM by Bruce Bullis

    Trying to import mov's from a selected folder into Premiere.

    sbaden11 Level 1

      I have a script that prompts the user to select a folder containing mov files to import. Once the folder is selected Premiere goes through the process of importing but at the end of the import a error message pops up saying "Unsupported format or damaged file."

       

      I know the mov's are good because I can drag them into the project just fine.

       

      Here is my code:

       

      var proj = app.project;  

      var binName = 'Batch Files';  // Find or create a target bin.

      var targetBin = searchForBinWithName(binName);

       

       

      if (targetBin == 0) {

          app.project.rootItem.createBin(binName);

      }

       

       

      if (proj != null) {

          targetBin = searchForBinWithName(binName);

          targetBin.select();

         

          var movLocation = Folder.selectDialog ("Choose folder containing files to import", 0, true);

          var filesArray = movLocation.getFiles("*.mov");

         

          if (movLocation != null) {

              //var import_these = new Array;  // We have an array of File objects; importFiles() takes an array of paths.

             

              for (var i = 0; i < movLocation.length; i++) {

                  filesArray[i] = movLocation[i].fsName;

              }

              proj.importFiles(filesArray);

          }

      }

       

       

      function searchForBinWithName(name) {

          var numItemsAtRoot = app.project.rootItem.children.numItems;

          var foundBin = 0;

       

          for (var i = 0; i < numItemsAtRoot && foundBin == 0; i++) {

              var currentItem = app.project.rootItem.children[i];

       

              if (currentItem != null && currentItem.name == binName) {

                  foundBin = currentItem;

              }

          }

          return foundBin;

      }