3 Replies Latest reply on Jun 21, 2014 9:58 PM by gert verrept

    Output each page with a custom file name

    gert verrept Level 2

      We have 150 photos to place in an Indesign file with Data Merge. Each page has: the photo, the name and surname.

      Is it possible the export these pages as separate files but named with the file name of the photo?

      gert

        • 1. Re: Output each page with a custom file name
          [Jongware] Most Valuable Participant

          Sure it's possible. Try this -- don't forget to adjsut the export path and PDF preset name.

           

          exportPath = "c:/temp";  // Adjust to fit!
          exportPreset = "My Favourite Preset"; // Adjust to fit!
          
          for (p=0; p < app.activeDocument.pages.length; p++)
            processPage(app.activeDocument.pages[p]);
          
          function processPage (a_page)
          {
            var i, link;
            for (i=0; i<a_page.allGraphics.length; i++)
            {
              if (a_page.allGraphics[i].itemLink.isValid)
              {
                linkname = File(a_page.allGraphics[i].itemLink.filePath);
                app.pdfExportPreferences.pageRange = a_page.name;
                app.activeDocument.exportFile (ExportFormat.PDF_TYPE, File(exportPath+'/'+linkname.name.replace(/(\.[^.]+)$/, '.pdf')), false, app.pdfExportPresets.item(exportPreset));
                return;
              }
            }
          }
          
          • 2. Re: Output each page with a custom file name
            gert verrept Level 2

            @Jongware: Works great, but I'm having trouble in Photoshop to batch save the pdf's for web in jpg format (something I wasn't told in the beginning), the files keep getting the name of the first file( ?).

            Is it possible (because I saw the the export preferences are possible for jpg too) to modify this script a little so the output in directly jpg formatted in stead of the pdf format? I tried to change it, but it's giving the error "Failed to export, specify a page number".

            Thnks

            • 3. Re: Output each page with a custom file name
              gert verrept Level 2

              OK, found the Photoshop error in the action, so no problem doing it in two steps.

              Thnks for the help.