1 Reply Latest reply on Sep 13, 2016 6:03 AM by davidblatner

    Reproducible Crash with Windows InDesign CC 2015.4

    PeteBaumgartner Level 1

      The script below opens up to 10 InDesign documents from a folder of more than 10 InDesign documents, makes a simple edit and then saves the document.

       

      If the InDesign documents reside on a networked file server - this will crash. If the InDesign documents reside on the local drive - this script runs fine. Have gotten the crash on Windows 8 and 10. On Macs runs fine.

       

      In addition if the script is edited to close the document - after each save - it will run okay over the network and locally.

       

      Does anyone have any idea what could be going on here - the issue seems to be editing multiple docs over the net and then leaving them open. But why?

       

      InDesign CC2015.4

       

      Thanks !

         pete

       

       

       

       

      //------------------  progress bar

      pg={};

       

      pg.newProgress = function (maxval, str) {

          pg.pBarMax = maxval + 1;

          pg.pb_win = new Window('palette', str);

          pg.pbar = pg.pb_win.add('progressbar', undefined, 1, pg.pBarMax);

          pg.pbar.preferredSize = [300, 20];

          pg.pbar.value = 0;

          pg.pb_win.show();

      };

       

      pg.incProgress = function() {

          pg.pbar.value = pg.pbar.value + 1;

      };

       

      pg.closeProgress = function () {

          try {

              pg.pb_win.close();

          }

          catch (e) {

              $.writeln ("pg.closeProgress "+e);

          }

      };

      //------------------------

       

       

      function getTheFolder () {

            var tmp=Folder.selectDialog ("Select folder of InDEsign documents");

            if (tmp instanceof Folder) return tmp;

            return false;

      }

       

       

      function runTheBatch () {

          var fldr=getTheFolder();

          if (fldr==false) return;

          var i=0;

          var maxIterations  = 10;

          var myFileList=fldr.getFiles(/\.(indd)$/i);   // was (/\.(indd|indt)$/i)

       

       

          pg.newProgress  (maxIterations, "Test progress");

       

       

         do {

         

              for (var x=0; x<myFileList.length && i<maxIterations; x++) {

                  i++;

                  var fi = File(myFileList[x]);

                  if (fi instanceof File) {

                         app.scriptPreferences.userInteractionLevel=UserInteractionLevels.neverInteract;

       

       

                      var docRef = app.open(fi);

                      if (docRef instanceof Document){

                          doSomethingToDocument (docRef);

                          //docRef.close();

                           pg.incProgress();

                          $.writeln("Finished iteration "+i);

                      } else {

                          $.writeln ("Not a indd doc "+myFileList[x]);

                      }

       

       

                         app.scriptPreferences.userInteractionLevel=UserInteractionLevels.interactWithAll;

       

       

                 

                  } else {

                      $.writeln ("Not a file "+myFileList[x]);

                  }

              }

         } while (i <maxIterations );

         pg.closeProgress();

       

       

      }

       

       

       

       

      function doSomethingToDocument (docRef) {

          try {

              docRef.insertLabel("dirty","myDirtyValue");

              docRef.save();

          } catch (e) {

              $.writeln("doSomethingToDocument exception "+e);

          }

      }

       

       

       

      runTheBatch();

      alert ('done');