4 Replies Latest reply on Jun 1, 2015 7:16 AM by Trevorׅ

    combine multiple files into one

    BEGINNER_X Level 3

      Hi All,

       

      Request:

       

      1. Need to combine multiple files into one

      2. User already created destination doc

      3. Folder contains around 30 files(all files having 1 page only)

      4. Need to move one by one

       

      Script:

      1. Got this script from forum (Combine multiple documents)

      2. by using forum script, the output comes wrongly (comes side by side)

       

      Wrong output using below script:

      Screen Shot 2015-05-31 at 8.05.38 PM.png

       

      Needed Output:

      Screen Shot 2015-05-31 at 8.08.48 PM.png

       

       

      Modified slightly:

      #target indesign
      // set the destination document as the active document.
      var destination_doc = app.activeDocument;
      destination_doc.documentPreferences.allowPageShuffle = true;  
      destination_doc.spreads[-1].allowPageShuffle = true;  
      
      // select the source folder
      var sourceFolder = Folder.selectDialog("Select a folder with source InDesign files.");
      var fileList = sourceFolder.getFiles();
      fileList.sort();
      
      for ( var i = 0; i < fileList.length; i++ ) {
          var source_file = fileList[i];
          
          if ( source_file instanceof File && source_file.name.match(/\.indd$/i)) {
              app.open(source_file);
              var source_doc = app.open(source_file);  
              var sourcePages = app.activeDocument.pages.item(0);
              sourcePages.duplicate(LocationOptions.AFTER, source_doc.pages.item(0));
              sourcePages.move(LocationOptions.AFTER, destination_doc.pages.item(-1));
              app.activeDocument.close(SaveOptions.NO);
          }
      }
      

       

       

      Thanks in Advance

      Siraj