7 Replies Latest reply on Aug 23, 2016 4:58 AM by selvam214

    Can't add the old version files to book

    selvam214 Level 1

      Hi All,

      I'm working in CC2015, already we have the CS6 version files. I need to add the files in active book.

       

      Kindly check the below code and guide to me.

       

      Note: If the InDesign files are current version, no issue. But old version, the file can't add to book(save).

       

       

       

      myExtensions = [".indd"] ; var myFilteredFiles = new Array;  var myFolder; startDate= new Date();

      var myFolder = Folder.selectDialog("Select the folder containing the indesign files", "");

      if(myFolder != null){

      if(File.fs == "Macintosh"){

          myFilteredFiles = MyMacOSFileFilter(myFolder);

          }

      else{

              myFilteredFiles = MyWinOSFileFilter(myFolder);

              }

          }

       

      var myBookFileName ,myBookFileName_temp;

      if (myFolder != null){

          var myFiles = [];

          var myAllFilesList = myFolder.getFiles("*.indd");

          for (var f = 0; f < myAllFilesList.length; f++){

              var myFile = myAllFilesList[f];

              myFiles.push(myFile);

              }

          if ( myFiles.length > 0)

          {

              if (app.books.length != 0) {

                  var myBook = app.activeBook;

                  myBook.close(SaveOptions.no); 

              }

              myBookFileName = myFolder + "/"+ myFolder.name + ".indb";

             

              myBookFileName_temp=myFolder.name;

              myBookFile = new File( myBookFileName);

              myBook = app.books.add(myBookFile);

              myBook.automaticPagination = false;

              for ( i=0; i < myFiles.length; i++){

                      myBook.bookContents.add(myFiles[i]);//struggle from here

                  }

              }

          }

       

       

       

       

       

       

      Selva

        • 1. Re: Can't add the old version files to book
          AriEss Level 1

          There seems to be some missing code. Where's the MyMacOSFileFilter and MyWinOSFileFilter functions?

          • 2. Re: Can't add the old version files to book
            Laubender Adobe Community Professional & MVP

            Hi Selva,

            did you try to do it without scripting?
            Could you add the CS6 documents to a CC 2015 book file without opening and saving the CS6 docs to CC 2015?

             

            Best,
            Uwe

            • 3. Re: Can't add the old version files to book
              selvam214 Level 1

              Hi Uwe,

              Yes I tried with manual and I have added with opening and saving method only.

               

              So, I will try to open and save method before add the files to book?

               

               

               

               

              Thanks,

              Selva

              • 4. Re: Can't add the old version files to book
                Laubender Adobe Community Professional & MVP

                selvam214 wrote:

                … So, I will try to open and save method before add the files to book? …

                 

                Exactly.
                But I would not do it with the original CS6 documents. Instead use duplicates so you can go back in case something is going wrong.

                 

                Best,
                Uwe

                • 5. Re: Can't add the old version files to book
                  selvam214 Level 1

                  Thanks for your guidance Uwe.

                   

                  Thanks,

                  Selva

                  • 6. Re: Can't add the old version files to book
                    selvam214 Level 1

                    Hi AriEss,

                     

                    Here are the functions,

                     

                     

                     

                     

                    //Windows version of the file filter.

                    function MyWinOSFileFilter(myFolder){

                        var myFiles = new Array;

                       

                        for(myExtensionCounter = 0; myExtensionCounter < myExtensions.length; myExtensionCounter++){

                            var myExtension = myExtensions[myExtensionCounter];        

                            myFiles = myFolder.getFiles("*"+ myExtension);

                            if(myFiles.length != 0){

                                for(var myFileCounter = 0; myFileCounter < myFiles.length; myFileCounter++){

                                    myFilteredFiles.push(myFiles[myFileCounter]);

                                }

                            }

                                     

                            //Get subfolder        

                            myFiles = myFolder.getFiles();

                            if(myFiles.length != 0){

                                for(var myFileCounter = 0; myFileCounter < myFiles.length; myFileCounter++){

                                    var myFile=myFiles[myFileCounter];

                                    if (myFile instanceof Folder){

                                        MyWinOSFileFilter(myFile);

                                    }

                                }            

                             }

                        }   

                        return myFilteredFiles;

                    }

                     

                    //Mac OS version of the file filter.

                    function MyMacOSFileFilter(myFolder){

                            var myFiles = new Array;

                            myFiles = myFolder.getFiles();

                            if(myFiles.length != 0){

                                for(var myFileCounter = 0; myFileCounter < myFiles.length; myFileCounter++){

                                    var myFile=myFiles[myFileCounter];

                                   

                    //----Get Sub folder-----               

                                   

                                    if (myFile instanceof Folder){

                                        MyMacOSFileFilter(myFile);

                                    } else{

                                        if(MyFileFilter(myFile)==true){

                                            myFilteredFiles.push(myFile);

                                        }

                                    }

                                }            

                             }   

                        return myFilteredFiles;

                    }

                     

                    function MyFileFilter(myFile){

                        var myFileType = myFile.type;

                        switch (myFileType){

                            case "IDd5":

                                return true;

                                break;

                            default:

                            for(var myCounter = 0; myCounter<myExtensions.length; myCounter++){

                                var myExtension = myExtensions[myCounter];    

                                if(myFile.name.substring(myFile.name.length-5).toLowerCase()==myExtension){

                                    return true;

                                    break;           

                                }

                            }

                        }

                        return false;   

                    }

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                     

                    Thanks,

                    Selva

                    • 7. Re: Can't add the old version files to book
                      selvam214 Level 1

                      Thanks Uwe,

                       

                      Finally I have followed before file saving method.

                       

                       

                      Selva