Export pages to jpg with custom file names

Hello world

I found - and slightly modified - this script that exports each InDesign page in jpg format, naming it with the relative page number.

I need to assign the value of a text that I have placed on each page, which is decorated with a paragraph called "filename" style file name

It would also be good to have user-friendly web file names, replacing spaces with dashes and turn them into tiny.

Thanks in advance for your help.

if (app.documents.length != 0) {
     var myDoc = app.activeDocument;
    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.high; // low medium high maximum
          app.jpegExportPreferences.exportResolution = 72;
          app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
          app.jpegExportPreferences.pageString = myPageName;

          var myFilePath = "~/Desktop/" + myPageName + ".jpg";
          var myFile = new File(myFilePath);
          myDoc.exportFile(ExportFormat.jpg, myFile, false);
     }
}

This code is the same as above, but with a few modifications and a new fuction

if (app.documents.length != 0) {
     var myDoc = app.activeDocument;
    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;
          var myJpegPrefix = "";
          var isStyleExist = true;

          //Checking the existing of the paragraph style (filename)
          try {
              myDoc.paragraphStyles.item("filename");
          }
          catch (myError) {
              isStyleExist = false;
          }

          if (isStyleExist)
            myJpegPrefix = getParagraphContent(myDoc.paragraphStyles.item("filename"), myDoc.pages.item(myCounter)) + myPageName;
          app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high; // low medium high maximum
          app.jpegExportPreferences.exportResolution = 72;
          app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
          app.jpegExportPreferences.pageString = myPageName;

          var myFilePath = "~/Desktop/" + myJpegPrefix + ".jpg";
          var myFile = new File(myFilePath);
          myDoc.exportFile(ExportFormat.jpg, myFile, false);
     }
}

// The new function, but needs to add checking the file name rules.

function getParagraphContent (paragraphStyle, currentPage) {
    var paragraphContent = "";
    for (var c = 0; c < currentPage.textFrames.length; c++) {
        for (var i = 0; i < currentPage.textFrames.item(c).paragraphs.length; i++){
            if (currentPage.textFrames.item(c).paragraphs.item(i).appliedParagraphStyle == paragraphStyle) {
                paragraphContent = currentPage.textFrames.item(c).paragraphs.item(i).contents;
                return paragraphContent;
            }
        }
    }
    return paragraphContent;
}

Lack of check file naming rules.

Tags: InDesign

Similar Questions

  • Each page with a custom file name output

    We have 150 photos to be placed in an Indesign file with data merge. Each page has: photo, name and first name.

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

    Gert

    It is of course possible. Try this: don't forget to date the export path and name of the PDF preset.

    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		   
  • 5.6.1 pages how to insert a file name

    In previous versions of Pages I could insert the file name or the full path of a document in the foot. I create multiple documents for our society. This has been invaluable when changes had to be made to a document or form. I can't find this option in Pages 5.6.1. Where at - it go? How can I insert a file name?

    Pages v5 (all versions) has been a complete rewrite - no no from the Pages ' 09. Insert menu: file name was never added to the application. There is no provision in the application of v5 Pages to insert the entire path either.

    If you click on the document name in the title bar, a Panel opens with the file name have been screened, and paste that in your footer. He was never a capacity in Pages ' 09 to insert a path of the document.

    The following AppleScript will display a POSIX path for the currently open document in Pages. It will support installation of Pages three different scenarios:

    1. V5 installed only with the open document pages
    2. Pages ' 09 installed only with the open document
    3. V5 pages and Pages ' 09 installed and running with open document

    Launch the Script Editor (Launchpad: others: Script Editor). Copy and paste the AppleScript in Script Editor. All text will be purple (normal). Click on the hammer icon to compile. Now the text is mixed of colors (good). Two successive stops:

    1. File menu: Save... File name: Pages_path. When you select the text in the File Format: selector, applescript is added file name. No other check boxes, and then save in your Documents folder. It is the only source.
    2. File menu: Option key: Save under... Pages_path. Since the File Format: selector, select Application. A .app extension will be added file name. Click on the box to hide the Extension. Save to your desktop. This is the clickable application.
    3. When you want the complete path of the open document, you click on the Pages_path icon on your desktop and a dialog box is displayed. Select, copy and paste this path into your Pages document.

    -Pages_path - display the full path of the current document

    -path can be copied and pasted into the dialog box in the document

    -Manages three scenarios

    (1) pages v5 only

    (--2) pages ' 09 only

    (--3) pages ' 09 and v5 both installed, but a race

    game of p9 to ((path to the applications folder) as text) & ' iWork ' 09: "&" Pages.app: "

    if (version of application 'Pages') is superior to "4.3" then

    -All Pages v5 release open with document

    say application 'Pages' to the value document_path to POSIX path of ((front file) document in the text)

    else if there are (p9) then

    -Pages ' 09 open with the document

    say my front document to set document_path to path it request p9

    on the other

    -OS X App Store Pages ' 09 only installed

    say application 'Pages' to the value document_path in front of path

    end if

    display the dialog box "Path of current document" & return & document_path as text

    return

  • Need help with script java folder level for silent registration with unique file name

    That's what I'm trying to do

    1. when a person completes the request on one of our computers in the office, there will be a button send at the bottom of the application.

    2 submit the application on is automatically stored on the local server with the file name determined by the fields name and surname on the application.

    example - John Doe Application.pdf

    Saved in the folder C:\Users\Station1\Desktop\FinishedApplication.jpgApplications

    3. This is the example of code I found, but I don't know how to enter which fields determine save name and where to save it to.

    http://thelivecycle.blogspot.de/2015/06/save-with-new-name-in-specified.html

    http://thelivecycle.blogspot.de/2015/06/save-with-new-name-in-specified.html http://thelivecycle.blogspot.com/2009/11/save-form-to-specific-directories-and.html

    Thank you!

    Lol this is the part that you need as a script to the folder level:

    var lcbSaveAs = app.trustedFunction (function (vDoc, vPath) {}

    app.beginPriv ();

    vDoc.saveAs ({cPath: vPath});

    app.endPriv ();

    });

    This is the code you use in your file:

    lcbSaveAs (, "/ C/users/specialisee1/Desktop/result /" + this.getField("FirstName").valueAsString + "" + this.getField("LastName").valueAsString + "Application.pdf");

    lcbSaveAs is the name of the function of trust.

    vDoc.saveAs is the Document object, call the saveAs method.

    I don't know what oDoc.SaveAs is, or where you got it.

  • Rename presets with the file name

    Hi guys,.

    I currently using presets to change my image but the name is so angry, he does not follow any order naming, just a total mess. I am using a batch program rename to rename this (filename), then import it to lightroom and realize that the name has not changed.

    "I Googled it and look like I need to change the ' title = ' with the text editor to change the name in lightroom. But I will have hundreds of presets and cannot change each of them manually more (past 4 hours to change the name of the file).

    Are these anyway that I can change the name of the fastest presets? Any program that correspond to the "title =" with the file name?

    Thank you

    User presets, click with the right button on the preset in the develop module, and then choose Rename.

    Batch renaming presets of in Lightroom is not possible.

  • If export all Pages HTML or CSS, what file name to enter?

    When I want to export all pages in my png file to HTML or CSS, what filename must enter - the file name for the first page or the name of the file on the master page?  Is how important it?  Why ask that question if it exports a separate file for each page?

    OK, I had some time to test this. It doesn't matter what you name the file that all pages will be exported as the name. I will not name test of mine and he has not shown, is just page names. I used the html and images option and unchecked current page only.

  • How watermark with the file name?

    I've searched and searched and I can't find an easy way to do this... but it MUST be possible!

    Some (really clumsy) Solutions, I found:

    1. I can create a .csv with two columns, each list of filename for each image in a folder.  Then, using variables in PS, I use the first column as a variable image replacement and the 2nd column as a text replacement variable to export the files.  This solution is both your time and creates images that are all the same size.
    2. LR/Mogrify plugin 2 - what might do the trick, but it doesn't seem to work with the latest version of LR
      • (I get this error: an internal error occurred: LRCatalog; withCatalogDo has been marked obsolete in Lightroom 2.0 and is not supported from Lightroom 3.0) This call is necessary.)
    3. Somehow use a droplet, pulling on the name of the metadata file to generate a watermark text... which I can't figure out how to do.

    How can this be complicated?  There must be a clear Super button, Miss me him somewhere in LR, because I can't imagine NOT having need of this feature.

    Help, please!

    You can do it in the slideshow module. By clicking on the ABC button on the toolbar and choosing the file name in the menu dropdown. You can drag the text box anywhere to anchor it in the Center, downstairs, etc. top of page. You can print a whole batch to PDF. See image:

  • How to change a 'Save as pdf script docs' to include the custom file name suffix

    I am trying to add some efficiencies of larger projects buy reducing the number of steps needed to export to PDF. I want to add a custom chain file name.

    YOU WANT

    From:

    20131006_KK_Brochure_v1.PDF

    TO:

    20131006_KK_Brochure_v1_OUTLINES_PRINT.PDF

    However, I have problems with the code that I modified. The code below is the addition of "_OUTLINES_PRINT" as a prefix, rather than as a suffix.

    function getTargetFile (docName, ext, destFolder) {}

    newName = "_OUTLINES_PRINT"; var

    If (docName.indexOf('.') < 0) {}

    newName = docName + ext;

    } else {}

    var point = docName.lastIndexOf('.');

    newName = docName.substring (0, dot);

    newName += ext;

    }

    Any help would be appreciated.

    Any help would be appreciated.

    change this line

    newName += docName.substring(0, dot);
    

    for this

    newName = docName.substring(0, dot)+newName;
    
  • Cannot delete files with long file names in Windows 7

    Unnecessary Windows 7 will not erase a file whose name is too long. I have no name, it is in a temporary folder of IE. I can't get rid of it as options to rename will not be visible.

    Thanks, but I have solved the problem. The error message was about 'file path or destination file name is too long. It is the backup to the temporary internet file that was causing a problem: he made the PATH too long as she added additional elements on the path. That was simply solved by the path to 2 bits, (path upper and lower file path) to cut and remove separately.

    When I tried to delete the .jpg image with the extremely long filename at the end of the long path he says as the destination folder (ie the TRASH) could not hold the file due to excessive length. It's confusing to say the least.

    Anyway that little trash has bit the dust.

  • Find photos with different file names?

    Somehow, I have photos with different names. Example: 2015-04-08 13.28.25.jpg and IMG_1668.JPG.

    Trying to get all the photos into the Lightroom Catalog, I am unable to find any pictures unless I know the two names - which I did not.

    And my DuplicateFinder are not nameless a base file name.

    Any ideas?

    Sheila

    Lightroom doesn't have a function automated for something like that, but there are third-party plug-ins. See, for example, here: Finding of pictures duplicate in Lightroom

  • Why Photoshop CC2015 open a RAW file with the file name right but wrong picture / not the picture that I chose?!!?!

    Suddenly new bug in my Photoshop CC 2015. It is a few days, he has begun to allow me to choose "open file", select a RAW file in my picture folder, click Open and then he shows me a different photo in RAW, but with the correct file name. That's happened? I changed nothing in the month and work on files Nikon or Canon RAW almost every day... that is something new that I need to find a patch or something that I am on... Help!

    Hi Modernmatt,

    I suggest you contact adobe support chat

    Please click on the link below-

    Contact the customer service

    Concerning

    Rohit

  • Bug in Apex 4.0.2 with APEX_MAIL file name parameter. ADD_ATTACHMENT

    When you call APEX_MAIL. ADD_ATTACHMENT where the filename parameter has value with more than a '. '. (punctuation), file name is not send correctly.

    Reproduction of the bug.
    p_filename=>'Report (2011.05.01).pdf'
    is received by post as
    Report (2011.).pdf
    Workaround solution:
    Change the value to have only 1 because punctuation in it.

    I think that this is not OK and that for a long time, the file is correct (that is, the number ': ' "------", "/" or special characters) it must be the same as it was.

    Hope this helps,
    Damir Vadas

    Published by: Damir Vadas may 18, 2011 18:56

    Damir,

    I tried to reproduce this on apex.oracle.com and could not. I sent a JPG file to my Yahoo account using the name "report (2011.05.01) .jpg ' and has no problems meeting." The name of the file received on Yahoo was still "report (2011.05.01) .jpg '.»

    I saw the code in APEX_MAIL. There is nothing that would change the file name as you suggest.

    Is there a chance it is changed in your SMTP server / relay?

    Joel

  • Open a RAW file with the file name right but wrong picture / no image I chose!

    Suddenly new bug in my Photoshop CC 2015. It is a few days, he has begun to allow me to choose "open file", select a RAW file in my picture folder, click Open and then he shows me a different photo in RAW, but with the correct file name. That's happened? I changed nothing in the month and work on Nikon or Canon RAW files almost daily. Help!

    You open the images of the bridge?  If so, try to purge the image cache

    What operating system do you use?

    You have everything installed miniature viewers?

    Problems with Canon and Nikon RAW files?  If just of Nikon, have already opened images with the Nikon RAW files Viewer?

  • Bringing data from Excel, same content with different file name

    Hello world

    I was download data from Excel files with success so far.

    The files that I used to download, have had the same 'FileName.xls '. Now, what I have is a workbook with a different name, so I guess as it was not created on the ODB like that he will not be transferred, in the name of the file is the same. Let me explain better.

    MYBEAUTIFULXLS.xls - before
    MYBEAUTIFULXLS_MORETEXT.xls - now

    Can I use something like MYBEAUTIFULXLS % somewhere on the ODI, for him to download data from the files that begin with the characters?

    I really appreciate your ideas!

    Best regards.

    J_ORCL

    Option 1 seems to be preferable, because there is risk associated with the 2nd.
    And debugging will also be little difficult.

    This is my personal opinion only... you can choose the desired option.

    Thank you
    Fati

  • Submit a form with specific file name

    Greetings!

    I'm not really any script, so I could really use some help.

    First of all – and especially:

    I have an Acrobat X Pro PDF form with a submit form button that is routed to a specific e-mail address.

    The native of Sharepoint and generates a file name long pdf filled with characters '% '.

    Is there a way to specify the name generated for the PDF file?

    I would be very happy if I can get the above scenario work...

    But I know that the question will be...

    Is to join a field of shape to this PDF file name anyway?

    As follows:

    SpecificFileName_EmployeenameField.PDF

    Still - I'm not a javascript person, otherwise I'd know if it was possible.

    And Yes, I'd like some recommendations on books / resources for scripts with Javascript.

    Thanks to anyone who can help to shed light on this.

    -You cannot specify the name of the file which is presented.

    -You can save the file by using the value of a field, but that requires a level of the file script installed on each user's computer using this file.

Maybe you are looking for

  • Lack of support for early 2009 Mac Pro

    When Apple says that they won't support not early 2009 Mac Pro for Sierra, they mean that they will not correct a problem if one occurs, or do they mean that just cannot run on the computer at all?  I only ask because my Mac Pro is much more powerful

  • Internal microphone does not work do not

    I tried to configure my headset on my laptop to use as a microphone, and I went to configure in speech recognition. I set up the microphone to the laptop by mistake and now barley microphone picks up no sound and I can't it go back to its original st

  • Car power adapter for C710-2490

    Problems to find a power adapter DC for my Chromebook C710-2490, which can connect on her cigarette lighter of my car. Can only find for other models of the C710, but not mine. Is the same as that used on the C710-2847 or 2478 - the power adapter? Th

  • Is there a way to know what physical events are happening in real time?

    I just had a problem from my phone since last week. I wouldn't do something unusual. Knows running programs with regard to my knowledge and visible only windows are concerned. And my hard drive would be thrown open. I don't know which program is the

  • RAY &amp; VSA - ACS 5.2 Appliance

    Hello I have found no documentation explaining how to create a specific attribute to the unit of ACS 5.2 for RADIUS authentication. I was able to do on ACS 4.0 ServerPour Netscreen Firewalls. We are migrating to ACS 5.2 device and before do us I want