Skip to main content
Participant
July 23, 2018
Question

Java Script - saving export directory

  • July 23, 2018
  • 1 reply
  • 432 views

Hi, let me begin by disclosing that I only have a very basic grasp of Java scripting. Assume nothing!

I am using a script which loads an InDesign template, imports images and text, exports a jpeg to one directory and saves the indd to another directory. Normally when you save an indd it also saves the last directory it was exported to. In this case it doesn't do that. If I manually re-export the jpeg the default directory is the same as that where the indd is saved and not the directory that the script exports to. So my question is, is there a way to force the export diectory to be saved? Relevant script section below. TIA

JavaScript

if ( renderFile) {

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

          app.jpegExportPreferences.exportResolution = 254; 

          app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange; 

          app.jpegExportPreferences.pageString = "1"; 

        

          var quantity = my_JSON_object.Quantity;

          var myFilePath = mySavePath+"/" + jobNumber + " " + finalImageName + "." + quantity + ".jpg";

          var myFile = new File(myFilePath);

        

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

         

           saveIndd(myDoc,myFolder,finalImageName,quantity) ;

          

          } else {

              alert ("Error Creating File");

              }

    // ########################   SAVE INDD

  function saveIndd( myDoc,myFolder,finalImageName,quantity) {  

var inddFile = new File (  myFolder+"/"  + jobNumber + " " + finalImageName +  "." +quantity + ".indd"); 

myDoc.save( inddFile )

    

myDoc.close();

}

This topic has been closed for replies.

1 reply

Loic.Aigon
Legend
July 25, 2018

I may have misunderstood something but as you cans save file to wherever you want, what's the issue ?

Participant
July 25, 2018

Hi, thanks for responding. Yes you are correct that I can export to wherever I want. My issue is a small but important one. As I am sure you know already, when you work normally with InDesign and export a file from it, the next time you export from the same InDesign file it will have 'remembered' the export directory, even if different from the directory where the InDesign file is saved. The issue here is that this doesn't occur when you using the Java Script above. When re-exporting, the export directory always defaults back to the directory where the indd is saved. Thanks again