3 Replies Latest reply on Sep 24, 2010 9:14 AM by behrk2

    Trouble cycling through a directory of InDesign Files

    behrk2

      Hello,

       

      I am writing a script that is meant to cycle through (open, process, close) a bunch of InDesign files in a specified directory.  I have this working except for the fact that the script is only opening one file and then after it closes that file, the script completes.  It will not cycle through all of the InDesign files in the folder.  Here is my code:

       

      var myFileLocation = Folder.selectDialog("Please select a folder containing the InDesign files.");

          myFolder = new Folder([myFileLocation]);
          myFolderContents = myFolder.getFiles("*.indd");
          myFileAmount = (myFolderContents.length - 1);

          // Open, Export, & Close
          for (i = myFileAmount; i >= 0; i--) {
              app.open(File(myFolderContents[i]));

              createHyperlinks();

              app.activeDocument.exportFile(
              ExportFormat.pdfType, File(myFolder.fsName + "/" + app.activeDocument.name.split(".indd")[0] + ".pdf"), false, myPreset);
              app.activeDocument.close(SaveOptions.no);
          }

       

       

      I have confirmed that myFileAmount contains the correct amount of files in the specified directory (35 files).  Also, I have confirmed that each one of those files is indeed the correct file type. Can anyone see anything wrong with my logic?

       

      Thanks!