3 Replies Latest reply on Aug 1, 2017 7:13 AM by S Hopkins

    Combine open documents into 1 file with AppleScript?


      Apologies if this has been asked before. I've had a good look around the forums but couldn't find anything.


      I'm in the process of writing a script to automate part of my workflow using AppleScript, and I've hit a stumbling block. The script produces a folder full of single page .indd documents. They're all the same size. What I want is to combine these documents into one multi page document. I thought it would be relatively simple to open all the docs and then just merge them together but I can't find anything in the InDesign AppleScript Guide and I'm lost. The script already names the files in such a way that their alphabetical order corresponds to the page order I would like them to be in once combined.


      If anybody could point me in the right direction, I'd be very grateful. I'm stumped. I'm using InDesign CC 2017.

        • 1. Re: Combine open documents into 1 file with AppleScript?
          Loic.Aigon Adobe Community Professional

          I guess I would create a book and export to PDF from it.

          • 2. Re: Combine open documents into 1 file with AppleScript?
            Laubender Adobe Community Professional & MVP

            Hi MrFive,

            combining documents means:
            Duplicate or move pages from one document to another document.

            There is a method for this in the DOM.


            Sorry, have no AppleScript code for this.
            In ExtendScript this would be something like this:


            var sourceDoc = app.documents[0];
            var targetDoc = app.documents[1];
            sourceDoc.pages.everyItem().duplicate( LocationOptions.AFTER , targetDoc.pages[-1] );


            But beware of side effects.
            Like new alternate layouts etc.pp.




            • 3. Re: Combine open documents into 1 file with AppleScript?
              S Hopkins Adobe Community Professional

              Here is an AppleScript to get you started hopefully in the right direction. It has the user choose the folder with the documents and then repeats through the list using rest of list. Hope this is helpful.



              set theFolder to choose folder

              set fileList to list folder theFolder without invisibles

              set fileRef to (theFolder as string) & item 1 of fileList


              tell application "Adobe InDesign CC 2017"

                set targetDoc to open fileRef

                set fileList to rest of fileList

                repeat while length of fileList > 0

                set sourceDocName to item 1 of fileList

                set sourceDocRef to open (theFolder as string) & sourceDocName

                set sourcePages to every spread of sourceDocRef

                duplicate sourcePages to after spread -1 of targetDoc

                set fileList to rest of fileList

                end repeat

              end tell