Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Prompt for export location

Guest
May 26, 2010 May 26, 2010

Hello,

I am creating a simple script to automate exporting a document as a pdf. How can I prompt the user for the export location with a file browser dialog? (Using javascript). Here is the script:

----

// choose PDF preset
var myPDFExportPreset = app.pdfExportPresets.item("PRESS");


// get document name
var myDocName = app.activeDocument.name;


// remove .indd from filename
var newDocName = myDocName.substring(0,myDocName.length-5);


// create exported filename
var myFile = File("/c/"+newDocName+" - PRESS.pdf");


// export the PDF
app.activeDocument.exportFile(ExportFormat.pdfType, myFile,false, myPDFExportPreset);

----

Right now it exports the PDF to /c/ - but I'd like to be able to browse for the export location. Can this be done?

TOPICS
Scripting
641
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , May 26, 2010 May 26, 2010

You can select a folder with Folder.selectDialog()

Try with below code:

// choose PDF preset
var myPDFExportPreset = app.pdfExportPresets.item("PRESS");

// get document name
var myDocName = app.activeDocument.name;

// remove .indd from filename
var newDocName = myDocName.substring(0,myDocName.length-5);

//select output folder
var myOutputFolder = Folder.selectDialog( 'Select output folder');

// create exported filename
var myFile = File(myOutputFolder + "/" + newDocName + " - PRESS.pdf");

// export the PDF
a

...
Translate
Engaged ,
May 26, 2010 May 26, 2010

You can select a folder with Folder.selectDialog()

Try with below code:

// choose PDF preset
var myPDFExportPreset = app.pdfExportPresets.item("PRESS");

// get document name
var myDocName = app.activeDocument.name;

// remove .indd from filename
var newDocName = myDocName.substring(0,myDocName.length-5);

//select output folder
var myOutputFolder = Folder.selectDialog( 'Select output folder');

// create exported filename
var myFile = File(myOutputFolder + "/" + newDocName + " - PRESS.pdf");

// export the PDF
app.activeDocument.exportFile(ExportFormat.pdfType, myFile,false, myPDFExportPreset);

Shonky

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 27, 2010 May 27, 2010
LATEST

Perfect! Thank you very much.


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines