17 Replies Latest reply on Jun 17, 2014 8:59 AM by Eugene Tyson

    Create PDF within group of folders?

    Eugene Tyson Adobe Community Professional & MVP

      Hi, everyone

       

      I am wondering if anyone knows of a script to batch convert a folder with subfolders of InDesign files to a PDF?

       

      I have a batch convert script - http://www.kahrel.plus.com/indesign/batch_convert.html

       

      Which helped me package all my files into folders very quickly.

       

      But I now I need to keep a PDF within all the folders.

       

      When I run the script again to create PDFs it only saves them to the root folder.

       

      What I need is to save all the PDFs to the same folder - or ideally to a folder called "Internal Proofs"

       

      For example I have:

       

      2014

      >Accounts
      >>Direct Debit Mandate

      >>>Document Fonts

      >>>Links

      >>>Direct Debit Mandate.indd

       

      What I need is

      >Accounts
      >>Direct Debit Mandate

      >>>Document Fonts

      >>>Links

      >>>Internal Proofs

      >>>>Direct Debit Mandate.pdf

      >>>Direct Debit Mandate.indd

       

       

      Can anyone help?

        • 1. Re: Create PDF within group of folders?
          TᴀW Adobe Community Professional & MVP

          Hi Eugene,

           

          The script has been saved as a jsxbin file, meaning that it can't be modified.

           

          Your best bet is probably to get in touch with Peter Kahrel and see if he can help.

           

          I suppose a separate script could be written to move the PDFs to the desired folder...

           

          Ariel


          • 2. Re: Create PDF within group of folders?
            Eugene Tyson Adobe Community Professional & MVP

            No way to have a script to generate a folder and produce a pdf into that folder based on the location of the indesign file?

            • 3. Re: Re: Create PDF within group of folders?
              Chinnadk Level 4

              Try this.

               

              var selectfolder, root, win = new Window("dialog", 'Package', [0,0,505,110], );
              with(win){
                win.panel = add( "panel", [5,5,500,105], undefined );
                with(win.panel){
                win.panel.rootfolder = add( "edittext", [5,3,355,23], undefined );
                win.panel.buttonrootfolder = add( "button", [360,1,485,23], 'Root folder' );
                      win.panel.buttonrootfolder.onClick = function (){
                              root =Folder.selectDialog("Root folder");
                              win.panel.rootfolder.text = root;
                          }
                win.panel.packagefolder = add( "edittext", [5,33,355,53], undefined );
                win.panel.buttonpackagefolder = add( "button", [360,32,485,54], 'Package path' );
                      win.panel.buttonpackagefolder.onClick = function (){
                          selectfolder = Folder.selectDialog ("Package path");
                          win.panel.packagefolder.text = selectfolder;
                          }
                win.panel.but = add( "button", [315,67,395,89], 'Ok' );
              
              
                win.panel.but = add( "button", [400,67,485,89], 'Cancel' );
                      win.panel.but.onClick = function (){
                      win.close ();
                          }
                }
                }
              win.center();
              win.show();
              
              var myfiles = [];
              getsubfolderfiles(root);
              
              
              for(var i =0;i<myfiles.length;i++)
              {
                      var doc = app.open(myfiles[i],false);
                      doc.packageForPrint(new Folder(selectfolder + "/"+myfiles[i].name.replace(".indd","")), true, true, false, false, true, false, true);
                      var pdfpath = new Folder(selectfolder + "/"+myfiles[i].name.replace(".indd","") + "/Internal Proofs/");
                      pdfpath.create();
                      doc.exportFile(ExportFormat.PDF_TYPE, new File(pdfpath+"/"+myfiles[i].name.replace(".indd", ".pdf")), false); 
                      doc.close();
                  }
              
              function getsubfolderfiles(folder)
              {
                  var filelist = folder.getFiles();
                  for(var i =0;i<filelist.length;i++)
                  {
                      if(filelist[i] instanceof Folder)
                      {
                          getsubfolderfiles (filelist[i]);
                      }
                      else if(filelist[i] instanceof File)
                      {
                          myfiles.push(filelist[i]);
                      }
                  }
              }
              

               

              Regards,

              Chinna

              • 4. Re: Create PDF within group of folders?
                Eugene Tyson Adobe Community Professional & MVP

                Thanks - I get this error though

                 

                Untitled-1.png

                • 5. Re: Create PDF within group of folders?
                  Chinnadk Level 4

                  Replace 45th line with : var filelist = folder.getFiles("*.indd");

                   

                  Regards,

                  Chinna

                  • 6. Re: Create PDF within group of folders?
                    Eugene Tyson Adobe Community Professional & MVP

                    Do you mean the 35th line?

                    • 7. Re: Create PDF within group of folders?
                      Eugene Tyson Adobe Community Professional & MVP

                      I replaced the line on the 45th line - as suggested, now the script doesn't do anything.

                       

                      It simply closes the dialogue and nothing happens.

                      • 8. Re: Re: Create PDF within group of folders?
                        Chinnadk Level 4

                        Try now,

                         

                        var selectfolder, root, win = new Window("dialog", 'Package', [0,0,505,110], );
                        with(win){
                          win.panel = add( "panel", [5,5,500,105], undefined );
                          with(win.panel){
                          win.panel.rootfolder = add( "edittext", [5,3,355,23], undefined );
                          win.panel.buttonrootfolder = add( "button", [360,1,485,23], 'Root folder' );
                                 win.panel.buttonrootfolder.onClick = function (){
                                        root =Folder.selectDialog("Root folder");
                                        win.panel.rootfolder.text = root;
                                    }
                          win.panel.packagefolder = add( "edittext", [5,33,355,53], undefined );
                          win.panel.buttonpackagefolder = add( "button", [360,32,485,54], 'Package path' );
                                 win.panel.buttonpackagefolder.onClick = function (){
                                    selectfolder = Folder.selectDialog ("Package path");
                                    win.panel.packagefolder.text = selectfolder;
                                    }
                          win.panel.but = add( "button", [315,67,395,89], 'Ok' );
                        
                        
                          win.panel.but = add( "button", [400,67,485,89], 'Cancel' );
                                 win.panel.but.onClick = function (){
                                 win.close ();
                                    }
                          }
                          }
                        win.center();
                        win.show();
                        var myfiles = [];
                        getsubfolderfiles(root);
                        for(var i =0;i<myfiles.length;i++)
                        {
                                var doc = app.open(myfiles[i],false);
                                doc.packageForPrint(new Folder(selectfolder + "/"+myfiles[i].name.replace(".indd","")), true, true, false, false, true, false, true);
                                var pdfpath = new Folder(selectfolder + "/"+myfiles[i].name.replace(".indd","") + "/Internal Proofs/");
                                pdfpath.create();
                                doc.exportFile(ExportFormat.PDF_TYPE, new File(pdfpath+"/"+myfiles[i].name.replace(".indd", ".pdf")), false);  
                                doc.close();
                            }
                        function getsubfolderfiles(folder)
                        {
                            var filelist = folder.getFiles("*.indd");
                            for(var i =0;i<filelist.length;i++)
                            {
                                if(filelist[i] instanceof Folder)
                                {
                                    getsubfolderfiles (filelist[i]);
                                }
                                else if(filelist[i] instanceof File)
                                {
                                    myfiles.push(filelist[i]);
                                }
                            }
                        }
                        
                        • 9. Re: Create PDF within group of folders?
                          Eugene Tyson Adobe Community Professional & MVP

                          Ok thanks - that's very close to what I am after!

                           

                          My folder structure is

                           

                          2014

                          ->Accounts

                          ----->Direct Debit Mandate

                          -------->Links

                          -------->Fonts

                          -------->Direct Debit Mandate.indd

                           

                           

                          When I run on the script on the root folder "2014" nothing happens, same thing with "Accounts" folder.

                           

                          I would really like to run the script from the "2014" root folder rather than going into each folder separately.

                          • 10. Re: Create PDF within group of folders?
                            Chinnadk Level 4

                            Are you looking for only pdf creation or both package and pdf. Your folder structure looks already packaged.

                            • 11. Re: Create PDF within group of folders?
                              Eugene Tyson Adobe Community Professional & MVP

                              I have used the Batch Convert script to package the files.

                               

                              I do need a PDF stored with the files - ideally an "Internal Proof" folder.

                               

                              Now, the Batch Convert script can scan all the folders and make a PDF - but it puts the PDFs in the Root folder at 2014.

                               

                              To put it in perspective, I have over 5,000 files to create a PDF for. I really don't want to do it manually. I really need the PDF stored with the jobs.

                              • 12. Re: Create PDF within group of folders?
                                Eugene Tyson Adobe Community Professional & MVP

                                To answer your question - if it could package and create the PDF that would be brilliant!

                                 

                                If not - I can use the Batch Convert script to package all the files. But ideally I need a PDF stored with each job in it's own folders.

                                • 13. Re: Re: Create PDF within group of folders?
                                  Chinnadk Level 4

                                  Hi,

                                   

                                  Sorry, i made a small mistake.

                                   

                                  Try now it will create package and pdf.

                                  var selectfolder, root, win = new Window("dialog", 'Package', [0,0,505,110], );
                                  
                                  
                                  with(win){
                                    win.panel = add( "panel", [5,5,500,105], undefined );
                                    with(win.panel){
                                    win.panel.rootfolder = add( "edittext", [5,3,355,23], undefined );
                                    win.panel.buttonrootfolder = add( "button", [360,1,485,23], 'Root folder' );
                                           win.panel.buttonrootfolder.onClick = function (){
                                                  root =Folder.selectDialog("Root folder");
                                                  win.panel.rootfolder.text = root;
                                              }
                                    win.panel.packagefolder = add( "edittext", [5,33,355,53], undefined );
                                    win.panel.buttonpackagefolder = add( "button", [360,32,485,54], 'Package path' );
                                           win.panel.buttonpackagefolder.onClick = function (){
                                              selectfolder = Folder.selectDialog ("Package path");
                                              win.panel.packagefolder.text = selectfolder;
                                              }
                                    win.panel.but = add( "button", [315,67,395,89], 'Ok' );
                                  
                                  
                                    win.panel.but = add( "button", [400,67,485,89], 'Cancel' );
                                           win.panel.but.onClick = function (){
                                           win.close ();
                                              }
                                    }
                                    }
                                  win.center();
                                  win.show();
                                  
                                  
                                  var myfiles = [];
                                  getsubfolderfiles(root);
                                  
                                  
                                  for(var i =0;i<myfiles.length;i++)
                                  {
                                          var doc = app.open(myfiles[i],false);
                                          doc.packageForPrint(new Folder(selectfolder + "/"+myfiles[i].name.replace(".indd","")), true, true, false, false, true, false, true);
                                          var pdfpath = new Folder(selectfolder + "/"+myfiles[i].name.replace(".indd","") + "/Internal Proofs/");
                                          pdfpath.create();
                                          doc.exportFile(ExportFormat.PDF_TYPE, new File(pdfpath+"/"+myfiles[i].name.replace(".indd", ".pdf")), false);  
                                          doc.close();
                                      }
                                  
                                  
                                  function getsubfolderfiles(folder)
                                  {
                                      var filelist = folder.getFiles();
                                      for(var i =0;i<filelist.length;i++)
                                      {
                                          if(filelist[i] instanceof Folder)
                                          {
                                              getsubfolderfiles (filelist[i]);
                                          }
                                          else if(filelist[i] instanceof File)
                                          {
                                              if(filelist[i].name.indexOf(".indd") > -1){
                                                  myfiles.push(filelist[i]);
                                              }
                                          }
                                      }
                                  }
                                  

                                   

                                  Regards,

                                  Chinna

                                  • 14. Re: Re: Re: Create PDF within group of folders?
                                    Chinnadk Level 4

                                    And this will create only pdf.

                                     

                                    var root = Folder.selectDialog("Root folder");
                                    var myfiles = [];
                                    getsubfolderfiles(root);
                                    for(var i =0;i<myfiles.length;i++)
                                    {
                                            var doc = app.open(myfiles[i],false);
                                            var pdfpath = new Folder(myfiles[i].path.replace(".indd","") + "/Internal Proofs/");
                                            pdfpath.create();
                                            doc.exportFile(ExportFormat.PDF_TYPE, new File(pdfpath+"/"+myfiles[i].name.replace(".indd", ".pdf")), false); 
                                            doc.close();
                                        }
                                    function getsubfolderfiles(folder)
                                    {
                                        var filelist = folder.getFiles();
                                        for(var i =0;i<filelist.length;i++)
                                        {
                                            if(filelist[i] instanceof Folder)
                                            {
                                                getsubfolderfiles (filelist[i]);
                                            }
                                            else if(filelist[i] instanceof File)
                                            {
                                                if(filelist[i].name.indexOf(".indd") > -1){
                                                    myfiles.push(filelist[i]);
                                                }
                                            }
                                        }
                                    }
                                    

                                     

                                    Regards,

                                    Chinna

                                    • 15. Re: Create PDF within group of folders?
                                      Eugene Tyson Adobe Community Professional & MVP

                                      Thanks for the help so far.

                                       

                                      1. It's not packaging all the files.
                                      2. The folder structure is being lost
                                      3. Some folders have just the Internal Proof folder and the PDF within that folder, but no InDesign file, document fonts, or links.

                                       

                                      For example:

                                       

                                      2014 (folder)

                                      --->Accounts (folder)

                                      ------->Direct Debit Mandate (folder)

                                      -------->Links (folder)

                                      -------->Document Fonts(folder)

                                      -------->Direct Debit Mandate.indd

                                       

                                      Changes to

                                       

                                      Direct Debit Mandate (folder)

                                      --->Internal Proof (folder)

                                      --->Direct Debit Mandate.pdf

                                       

                                       

                                       

                                      I really need just an "internal proof folder" and the PDF to be generated to that folder.

                                       

                                      The structures need to remain in tact.

                                      • 16. Re: Create PDF within group of folders?
                                        Eugene Tyson Adobe Community Professional & MVP

                                        An example of another folder structure would be

                                         

                                        2014 (folder)

                                        --->Education (folder)

                                        --->External Adverts (folder)

                                        ------->Irish Times (folder)

                                        ------------>Full Page (folder)

                                        ------------------>document fonts (folder)

                                        ------------------>links (folder)

                                        ------------------>fp advert.indd

                                        ------------> Half Page (folder)

                                        ------------------>document fonts (folder)

                                        ------------------>links (folder)

                                        ------------------>hp advert.indd

                                         

                                        etc.

                                         

                                        Right now it's just going to folders such as

                                         

                                        Full Page

                                        ------>Internal Proofs

                                        ------>fp advert.pdf

                                         

                                        with no InDesign file, no document links and no links folder.

                                         

                                        Plus I need it to retain the file structure.

                                        • 17. Re: Create PDF within group of folders?
                                          Eugene Tyson Adobe Community Professional & MVP

                                          Thank you so much for all the help so far.

                                           

                                          I however, am an idiot - I can run the Batch Script to convert all the files - if I don't use  an Output Path it will create all the PDFs inside it's own folder.

                                           

                                          Thanks - but I don't need the script - the batch convert will do that for me.