9 Replies Latest reply on Feb 25, 2016 6:28 AM by laura972

    Export in JPG with rename

    laura972

      Hallo everyone,

       

      I have an IndesignCS6 file with 4 pages.

      Each page has a different size.

      Each page cointains the same graphic resized.

       

      I need to export each page in jpg, I need each page to have a custom name like

       

      01_PrintXX_InKredible_4x5_Ratio

       

      02_PrintXX_InKredible_3x4_Ratio

       

      03_PrintXX_InKredible_2x3_Ratio

       

      04_PrintXX_InKredible_PaperSize

       

      would be great iif PrintXX could be the name of the indesign file (but this is optional)

      Is it possible?

       

      Thank you so much to anyone that can help me. Would be a lifesaver, I have more than 150 files to export in the 4 different sizes and rename

       

      Laura

        • 1. Re: Export in JPG with rename
          Ronald63 Level 4

          Hi Laura,

           

          Are different page sizes always in the same order ?

          Page 01 = 4x5_Ratio

          Page 02 = 3x4_Ratio

          Page 03 = 2x3_Ratio

          Page 04 = PaperSize

           

           

          • 2. Re: Export in JPG with rename
            laura972 Level 1

            yes!

            • 3. Re: Export in JPG with rename
              Jump_Over Level 5

              Hi,

               

              Try this:

              var
                exportPartNames = [
                "InKredible_4x5_Ratio",
                "InKredible_3x4_Ratio",
                "InKredible_2x3_Ratio",
                "InKredible_PaperSize"
                ],
                mDoc = app.activeDocument,
                destFolder = "~/Desktop/PDFs/",
                mPages = mDoc.pages.everyItem().getElements(),
                cPage, cPageName, mDocName = mDoc.name.replace(/\.indd$/,""),
                destFile;
              
                if (!File(destFolder).exists) Folder(destFolder).create();
              
                if (mPages.length != exportPartNames.length) {
                alert("Count of names doesn't match count of pages");
                exit();
                }
              
                with (app.jpegExportPreferences) {
                jpegColorSpace = JpegColorSpaceEnum.RGB;
                jpegQuality = JPEGOptionsQuality.HIGH;
                jpegExportRange = ExportRangeOrAllPages.EXPORT_RANGE;
                exportResolution = 72;
                }
              
                while ( cPage = mPages.shift() ) {
                cPageName = ("00" + (cPage.documentOffset + 1)).slice(-2);
                destFile = new File(destFolder + "/" + cPageName + "_" + mDocName + "_" + exportPartNames.shift() + ".jpg");
                app.jpegExportPreferences.pageString = cPage.name;
                mDoc.exportFile(ExportFormat.JPG, destFile, false);
                }
              

               

              Modify destFolder, exportPartNames ans jpegPref if needed

               

              Jarek

              • 4. Re: Export in JPG with rename
                laura972 Level 1

                thank you! thank you! thank you! thank you!

                it works!!

                it's just perfect, you saved my life

                • 5. Re: Export in JPG with rename
                  laura972 Level 1

                  Hi,

                   

                  it's me again! The script is just perfect. I have a small request if possible...

                   

                  is it possible to make the script to generate a folder named like the indesign file instead of generic 'Pdfs'? The script is an incredible timesaver, but I still have to manually rename all the folders.

                  Thank you so much


                  • 6. Re: Export in JPG with rename
                    Ronald63 Level 4

                    Hello,

                     

                    if I understand your request ...

                     

                     

                    var
                      exportPartNames = [
                      "InKredible_4x5_Ratio",
                      "InKredible_3x4_Ratio",
                      "InKredible_2x3_Ratio",
                      "InKredible_PaperSize"
                      ],
                      mDoc = app.activeDocument,
                      mPages = mDoc.pages.everyItem().getElements(),
                      cPage, cPageName, mDocName = mDoc.name.replace(/\.indd$/,""),
                      destFile,destFolder = "~/Desktop/" + mDocName + "/";
                    
                    
                      if (!File(destFolder).exists) Folder(destFolder).create();
                    
                      if (mPages.length != exportPartNames.length) {
                      alert("Count of names doesn't match count of pages");
                      exit();
                      }
                    
                      with (app.jpegExportPreferences) {
                      jpegColorSpace = JpegColorSpaceEnum.RGB;
                      jpegQuality = JPEGOptionsQuality.HIGH;
                      jpegExportRange = ExportRangeOrAllPages.EXPORT_RANGE;
                      exportResolution = 72;
                      }
                    
                      while ( cPage = mPages.shift() ) {
                      cPageName = ("00" + (cPage.documentOffset + 1)).slice(-2);
                      destFile = new File(destFolder + "/" + cPageName + "_" + mDocName + "_" + exportPartNames.shift() + ".jpg");
                      app.jpegExportPreferences.pageString = cPage.name;
                      mDoc.exportFile(ExportFormat.JPG, destFile, false);
                      }
                    
                    
                    
                    • 7. Re: Export in JPG with rename
                      laura972 Level 1

                      Hi,

                       

                      I've tried but it's seems not working..

                      I try to explain the best I can:

                      (I'm sorry I'm Italian and my english is not perfect. I hope you can understand.)

                       

                      The 'original' script is perfect and works great, only one 'feature' is missing (I did not requested as I realized I needed it when I started to work on the files :/ )

                      Now 4 files are generated inside a generic 'Pdfs' folder on desktop.

                      1.   destFolder = "~/Desktop/PDFs/", 


                      and I have to manually rename the folder with the name of the indesing file.

                      The indesign filename is simple like:  Print_xx. I have at least 150 files named print_01, print_02 ecc.. and it's really time consuming to change them manually after the folder is generated by the script.

                      It would be great if the folder name could, already be, the same name of my indesign file.

                       

                      Thank you

                      • 8. Re: Export in JPG with rename
                        Ronald63 Level 4

                        What is wrong with my code update ?

                         

                        I tested this code and it works ...


                        test.jpg

                        • 9. Re: Export in JPG with rename
                          laura972 Level 1

                          it's working now.

                          sorry the first time I tried several ways and I did not found any folder on desktop..

                          sorry, maybe I did something wrong!

                          Thanx a lot again!