1 Reply Latest reply on Oct 4, 2016 9:28 AM by Loic.Aigon

    Import IDML to end of activedoc

    jakec88782761 Level 2

      Hi,

       

      I'm trying to import idml files from a folder called SL translations into the activeDocument.

       

      For some reason the script doesn't get past the regexp which filters for idml files.

       

      Can anyone help me out?

       

      var targetFolder = Folder("A:/Work in progress/Jake/SL Translations/"),
      doc = app.activeDocument,
      fileList = targetFolder.getFiles();

      for (var i = 0; i < fileList.length; i++){
          var TL = fileList[i];
         
          if (TL.name.match("(?i)\\.idml$")){
             
              app.open(TL);
              var TLdoc = app.documents.item(TL.name);
              var TLpages = TLdoc.pages.everyItem().getElements();
             
              for (var j = 0; j <TLpages.length; j++){
                 
                  TLpages[i].appliedMaster=doc.appliedMaster;
                  }
             
              TLpages.duplicate();
              TLpages.move(LocationOptions.AFTER,doc.pages[-1]);
             
              app.activeDocument.close(SaveOptions.NO);
              }
          }

       

      Thanks guys