4 Replies Latest reply on Jan 26, 2011 11:34 PM by Jonas_P

    Script a pathlist to use when creating an Indesign book

    Jonas_P Level 1

      Is it possible to create a script from which you create an Indesign book? I have a path list where all my Indesign documents are located which I want to create a book of. Sadly the documents are located in seperate folders, that's why I can't multiselect all documents when adding them to the book. Insted I have to add one and one.

       

      The simpler the better.

      Thanks in advance

      http://forums.adobe.com/thread/782596?tstart=0

        • 1. Re: Script a pathlist to use when creating an Indesign book
          [Jongware]-9BC6tI Level 4

          Is that a list of paths (folders) which have to be scanned for every InDesign file in each, or a list of full paths to every single ID document?

          • 2. Re: Script a pathlist to use when creating an Indesign book
            Kasyan Servetsky Level 5

            A few days ago I wrote this script that creates a book from InDesign documents located in the selected folder (including it's subfolders). If the book with the same name as the selected folder already exists, the script just opens it.

            var myFolder = Folder.selectDialog( "Select a folder with InDesign files" );
            if ( myFolder != null ) {
                 var myFiles = [];
                 
                 GetSubFolders(myFolder);
                 
                 if ( myFiles.length > 0 ) {
                      var myBookFileName = myFolder + "/"+ myFolder.name + ".indb";
                      myBookFile = new File( myBookFileName );
                      if ( myBookFile.exists ) {
                           if ( app.books.item(myFolder.displayName + ".indb") == null ) {
                                myBook = app.open( myBookFile );
                           }
                      }
                      else {
                            myBook = app.books.add( myBookFile );
                            myBook.automaticPagination = false;
                            for ( i=0; i < myFiles.length; i++ ) {
                                myBook.bookContents.add( myFiles[i] );
                            }
                            myBook.save();
                       }
                 }
            }
            
            //=================================== FUNCTIONS =========================================
            function GetSubFolders(theFolder) {
                 var myFileList = theFolder.getFiles();
                 for (var i = 0; i < myFileList.length; i++) {
                      var myFile = myFileList[i];
                      if (myFile instanceof Folder){
                           GetSubFolders(myFile);
                      }
                      else if (myFile instanceof File && myFile.name.match(/\.indd$/i)) {
                           myFiles.push(myFile);
                      }
                 }
            }
            //--------------------------------------------------------------------------------------------------------------
            
            • 3. Re: Script a pathlist to use when creating an Indesign book
              Jonas_P Level 1

              It is full paths with both folder structure and file names.

               

              Any solutions nearby?

               

              I have a second though that maybe we could create a "daemon folder" where all files are listed, if so we could use the regular "add" procedure in indesign without the problem that we have to change folder for each new file. This daemon fools the computer to belive that all files are located in same folder, but in

              • 4. Re: Script a pathlist to use when creating an Indesign book
                Jonas_P Level 1

                Interesting, I'm not a code guru, not even close. But I will

                try it out.

                 

                I would need a If command that writes out if the files that does not exist after the book was created. Ie if I type an incorrect file name.

                 

                /Jonas