18 Replies Latest reply on Feb 16, 2015 12:58 PM by cummingsc2

    Combine multiple documents


      I have about 20 different indesign documents (some are 1 pg some are 3 pgs) and I want to combine them all into one indesign file (not a book).  Is there a script to do so?  I know you can manually go to each of the 20 documents and move the page to the main one, but I want a quicker way.  I found a script online but it's giving me an error on the bold, red line below after it imports 10 pages.  Any ideas?



      // set the destination document as the active document.
      var destination_doc = app.activeDocument;

      // select the source folder
      var sourceFolder = Folder.selectDialog(“Select a folder with source InDesign files.”);

      // if we’re not in the source folder, stop running the script.
      if ( !sourceFolder ) {

      // set file list and run through each file. Sorting them alphanumerically.
      var fileList = sourceFolder.getFiles();

      // run through each file
      for ( var i = 0; i < fileList.length; i++ ) {
      var source_file = fileList[i];

      // making sure it’s an indesign file…
      if ( source_file instanceof File && source_file.name.match(/\.indd$/i)) {
      var source_doc = app.documents.item(source_file.name);

      for ( var count = 0; count < source_doc.pages.length; count++ ) {
      var sourcePages = source_doc.pages.item(count);

      // break the master page items so they can be moved onto the new document.
      var masterItems = sourcePages.masterPageItems;
      if ( masterItems.length > 0 ) {
      for ( var j=0; j<masterItems.length; j++ ) {

      // removing the applied master (this can mess up some files if not done)

      // duplicating it in the original file (due to errors) and them moving it to
      // the destination document.
      sourcePages.duplicate(LocationOptions.AFTER, source_doc.pages.item(0));
      sourcePages.move(LocationOptions.AFTER, destination_doc.pages.item(-1));

      // closes the file that was opened without saving (to avoid memory problems)