Skip navigation
cdnyc
Currently Being Moderated

Export pages to jpg with custom filenames

Aug 16, 2010 12:47 PM

Trying to find out if there is a way I can export the pages of an InDesign document so that each exported jpg could have a unique name I am able to specify before exporting, instead of going in afterwards and renaming each one.

 
Replies 1 2 Previous Next
  • Currently Being Moderated
    Aug 16, 2010 12:52 PM   in reply to cdnyc

    Not really, the closest you will be able to get is Scott Zanelli's free Page Exporter Utility script, I'd google Indesign Secrets Page Exporter Utility and you should find it, sorry I can't give you the link at the moment.  It comes with a manual explaining how it works.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 16, 2010 4:09 PM   in reply to cdnyc

    You could also try something like Name Mangler http://manytricks.com/namemangler/ to batch rename. It'll save you some time. I often find this easiest.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 16, 2010 6:12 PM   in reply to FivePicaPica

    Depending on how handy you are with Javascript, it may be faster to write a custom jpeg-exporter script.

     

    (I'm a painfully slow scripter. When I'm on the Mac, I use NameMangler.)

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 18, 2010 10:06 AM   in reply to cdnyc

    Here I slapped up a script:

    if (app.documents.length != 0) {
         var myDoc = app.activeDocument;
         var myBaseName = prompt ("Enter basic name", GetFileNameOnly(myDoc.name), "Basic name");
         if (myBaseName != null) MakeJPEGfile();
    }
    else{  
         alert("Please open a document and try again.");  
    } 
     
    function MakeJPEGfile() { 
         for(var myCounter = 0; myCounter < myDoc.pages.length; myCounter++) {
              if (myDoc.pages.item(myCounter).appliedSection.name != "") {
                   myDoc.pages.item(myCounter).appliedSection.name = "";
              }
              var myPageName = myDoc.pages.item(myCounter).name;
              app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.medium; // low medium high maximum
              app.jpegExportPreferences.resolution = 72;
              app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
              app.jpegExportPreferences.pageString = myPageName;
              
              var myFilePath = "~/Desktop/" + myBaseName  + "_" + myPageName + ".jpg";
              var myFile = new File(myFilePath);
              myDoc.exportFile(ExportFormat.jpg, myFile, false);
         }
    }
     
    function GetFileNameOnly(myFileName) {
         var myString = "";
         var myResult = myFileName.lastIndexOf(".");
         if (myResult == -1) {
              myString = myFileName;
         }
         else {
              myString = myFileName.substr(0, myResult);
         }
         return myString;
    }
    

     

    Warning! The script removes section prefixes.

     

    Kasyan

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 18, 2010 10:49 AM   in reply to cdnyc
    1. Copy the script from the forum (make sure to copy the whole script , otherwise it won't work).
    2. Run Adobe ExtendToolkit (or Notepad)
    3. Create new document and paste
    4. Save it in Scripts Panel folder (either User or Application) -- you can quickly get there by Opt/Alt clicking on it in Scripts panel
    5. To run the script just double click its name in Scripts panel

     

    Kasyan

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 1, 2011 5:55 AM   in reply to Kasyan Servetsky

    I tried this with the InDesign CS5, but got error on this line:

     

    app.jpegExportPreferences.resolution = 72;

     

    How should I fix the line in order to get the script work?

     

    Thanks in advance!

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 1, 2011 8:20 AM   in reply to Kari Puikkonen

    I can't test it myself — don't have CS5 at hand. Try to change this line to

    app.jpegExportPreferences.exportResolution = 72;
    

     

    Kasyan

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 1, 2011 9:27 AM   in reply to Kasyan Servetsky

    That worked! Thnak you!

     

    Sent from my iPhone

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 1, 2011 12:30 PM   in reply to Kasyan Servetsky

    That worked! Thank you!

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 9, 2011 5:37 AM   in reply to cdnyc

    RE Export pages to jpg with custom filenames

     

    HELP PLEASE!!

     

    If I have 10 pages in my InDesign document and want to export all 10 pages at once as individualy named JPGs, what do I need to do?

     

    Do I have to use separators in the box that pops up when I execute the script, or amend the script in some way

    .

    Help would be greatly appreciated as it would save me hours of renaming time when my boss keeps changing his mind!!!

    Regards - Janice

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 9, 2011 5:51 AM   in reply to jchapmans

    For renaming files, use Bridge.

     

     

     

    Bob

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 9, 2011 6:07 AM   in reply to Bob Levine

    That won’t work for me as each page (over 200 of them) have unique names but always get exported with these unique names.

    eg bclol2pk.jpg bogofp.jpg and it goes on.

    Bridge will defiantly come in handy when I have to add the prefix for each new batch.

     

    The forum: http://forums.adobe.com/message/3063985 seemed to suggest I could run the script that could export each page as a unique JPG name.

     

    Thank you!

    Janice

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 9, 2011 6:13 AM   in reply to jchapmans

    Did you try the script in Post 5?

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 9, 2011 6:25 AM   in reply to Peter Spier

    Yes I have, but I don't get a unique name, except for the page number which I don't need. I get something like:

    ap11_1.jpg

    ap11_2.jpg

    ap11_3.jpg

    and so on.

     

    So I'm just getting the "Basic Name" which I specified when I ran the script and page names, BUT don't know how to get the unique name for each exported JPG.

    Thanks for your help!!

    Janice

     

    This would be perfect if I could get it to work.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 9, 2011 6:33 AM   in reply to jchapmans

    I guess I don't understand what you mean about each page has a unique name. Are you saying you need to export the pages to a series of unique names that have no realtion either to each other or to the original filename? I don't believe you will be able to automate that.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 9, 2011 6:45 AM   in reply to Peter Spier

    I just thought that within the script I could add a string so that the script for example would export:

     

    Export page 1 as : ap11_bogofp.jpg

    Export page 2 as : ap11_bcolpk.jpg

    Export page 3 as : ap11_bcolpkpap.jpg

    and so on

     

    Ah well, no harm in asking!!

    Thank you for your help!

    Kind regards - Janice

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 9, 2011 8:18 AM   in reply to jchapmans

    You could pick up names from an external text file (a more complex script), but you'd need to create that file. Otherwise, variable text in the string is probably limited to sequential numbers.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 9, 2011 8:34 AM   in reply to Peter Spier

    Thanks – I wouldn't know where to start.

    There may be someone at work who can help re scripts.

    Thank you again!!

    Janice

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 9, 2011 8:37 AM   in reply to jchapmans

    jchapmans wrote:

     

    I wouldn't know where to start.

     

    Think it over before asking in the scripting forum. Where would these file names come from?

     

    I just thought that within the script I could add a string so that the script for example would export:

     

    ...

     

    Well, where would these additional strings come from? It depends on what you want to use this script for -- if, for example, these postfixes are always these three "bogofp", "bcolpk" and "bcolpkpap", then it's a simple addition to the existing script. However, you say "and so on" so we'd have to know what to append to all other possible pages.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 9, 2011 10:30 AM   in reply to Peter Spier

    I’ve given up with on InDesign

    Played with fireworks – decided to get everything into Fireworks and individually name the slices – sorted!!

    Thank you for all you help!!

    Regards - Janice

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 10, 2011 12:55 AM   in reply to cdnyc

    Was it the script in this discussion or another script you used?

    Would you be able to post a sample please?

    Thank you – regards - Janice

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 10, 2011 6:48 AM   in reply to cdnyc

    Sorry nothing attached.

    I’m also using CS5.

    what is it I need to change in the script in post #5 above to tell it to export using the section names?

    If I can get this to work, it will be a life saver!!

    Thank you - Janice

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 10, 2011 9:11 AM   in reply to cdnyc

    I’ve can run the script, I just can’t get it to export the JPGs with the Section names.

    I only get the automates page numbering.

    I think I’ll have to give up.

    thank you for your help.

    Janice

     
    |
    Mark as:
  • John Hawkinson
    5,572 posts
    Jun 25, 2009
    Currently Being Moderated
    Oct 10, 2011 11:06 PM   in reply to cdnyc

    cdnyc:

    See #8-10 for modifying posted script to work in CS5. It's coded to pull from the section name, so nothing you should have to do.

    That's not what I see. It appears to simply blank out the section name:

    if (myDoc.pages.item(myCounter).appliedSection.name != "") {
        myDoc.pages.item(myCounter).appliedSection.name = "";
    }

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 5, 2011 3:22 AM   in reply to John Hawkinson

    John, you are right about that it will blank out the section name. After I have applied new section name this script will in some way reset section name back to "zero".

    I would be really greatfull if I could get this script to work with applying the section name, do you have any suggestions how to do this?

     
    |
    Mark as:
  • John Hawkinson
    5,572 posts
    Jun 25, 2009
    Currently Being Moderated
    Dec 5, 2011 6:14 AM   in reply to AndSchWall

    And:

    I don't really understand why Kasyan explicitly removes the section name, but you should be able to remove (or comment out) those 3 lines and have the script work. I also don't know what you mean by "applying the section name," though. Applying it to what?

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 5, 2011 7:25 AM   in reply to [Jongware]

    What would be awsome for me is a Text variable that can be inserted in the name of each page.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 6, 2011 12:07 AM   in reply to John Hawkinson

    Sorry for my bad english John, I removed the three lines and now it works the way I wanted to. It will now export .jpg files with the specific name I put in the section prefix. Thank you very much for your help!

     
    |
    Mark as:
  • John Hawkinson
    5,572 posts
    Jun 25, 2009
    Currently Being Moderated
    Dec 6, 2011 12:14 AM   in reply to AndSchWall

    You're welcome, AndSchWall.

     

    As for text variables, _acadamie, well, I think that's doable but more annoying. Try figuring it out yourself .

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 19, 2012 9:27 AM   in reply to Kasyan Servetsky

    First of all, thank you so much for this script. I know next to nothing about scripting, but I was able to modify this to rename our files for ad proofs (we got tired of clients 'cracking' our PDFs for other vendors). I was wondering, is there a way to modify the script so that it saves the exported file into the same folder as the file you're exporting from? We're working from a server, so this would save us a drag & drop each time.

     

    Thanks again.

     
    |
    Mark as:
  • John Hawkinson
    5,572 posts
    Jun 25, 2009
    Currently Being Moderated
    Jan 19, 2012 6:56 PM   in reply to TaraRebeka

    TaraRebeka: Yes, just replace this line:

     

              var myFilePath = "~/Desktop/" + myBaseName  + "_" + myPageName + ".jpg";

     

    with this:

     

              var myFilePath = myDoc.filePath + "/" + myBaseName  + "_" + myPageName + ".jpg";

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 20, 2012 7:35 AM   in reply to John Hawkinson

    Sir, you have made me a hero at work. Thank you!

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 25, 2012 5:34 AM   in reply to John Hawkinson

    Sorry to open up this post again, but I really can't get this to work with CS5.5
    I also would like to use this script so that I can export each page as a JPG and that it will use the Section prefix as the name for that JPG.

     

    I have the following code in Toolscript:

     

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

         var myDoc = app.activeDocument;

         var myBaseName = prompt ("Enter basic name", GetFileNameOnly(myDoc.name), "Basic name");

         if (myBaseName != null) MakeJPEGfile();

    }

    else{ 

         alert("Please open a document and try again."); 

    }

     

    function MakeJPEGfile() {

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

          /if (myDoc.pages.item(myCounter).appliedSection.name != "") {

            myDoc.pages.item(myCounter).appliedSection.name = "";

                      }

              var myPageName = myDoc.pages.item(myCounter).name;

              app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.medium; // low medium high maximum

              app.jpegExportPreferences.exportResolution = 72;

              app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;

              app.jpegExportPreferences.pageString = myPageName;

     

              var myFilePath = "~/Desktop/" + myBaseName  + "_" + myPageName + ".jpg";

              var myFile = new File(myFilePath);

              myDoc.exportFile(ExportFormat.jpg, myFile, false);

         }

    //}

     

    function GetFileNameOnly(myFileName) {

         var myString = "";

         var myResult = myFileName.lastIndexOf(".");

         if (myResult == -1) {

              myString = myFileName;

         }

         else {

              myString = myFileName.substr(0, myResult);

         }

         return myString;

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 12, 2012 11:27 PM   in reply to Peter Spier

    This is what I am looking for - do you know of such a script or can you help out?  I have a excel file where I have all the names in correct order 1 - name1; 2 - name2 etc.
    I am a mediocre user of indesign and cant write my own

     
    |
    Mark as:
1 2 Previous Next

More Like This

  • Retrieving data ...

Bookmarked By (1)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points