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

Can today's date be automatically added before the file name when export PDF?

Guide ,
Feb 05, 2025 Feb 05, 2025

Can today's date be automatically added before the file name when export PDF?
For example, my file name: myFile.indd
every time to add the day before the date, such as: 2025-02-05-myFile.pdf

 

I often change the ID file name directly, a little impatient.

 

I use a bit too many templates and sometimes I need to modify them temporarily.

Directly with the script export, can not temporarily modify the template.
Can you automatically modify the name when exporting?
Then only call the ID software comes with the interface to export PDF?

TOPICS
Feature request , How to , Import and export , Performance , Scripting
1.1K
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 , Feb 07, 2025 Feb 07, 2025
var myDocument = app.activeDocument;
var myFileName = myDocument.name.replace(/\.indd$/, ''); // Remove the .indd extension
var myDate = new Date();
var myYear = myDate.getFullYear();
var myMonth = ("0" + (myDate.getMonth() + 1)).slice(-2); // Add leading zero
var myDay = ("0" + myDate.getDate()).slice(-2); // Add leading zero
var myFormattedDate = myYear + "-" + myMonth + "-" + myDay;
var myPDFFile = new File(myDocument.filePath + "/" + myFormattedDate + "-" + myFileName + ".pdf");

// Create a
...
Translate
LEGEND ,
Feb 05, 2025 Feb 05, 2025

You mean "when exporting"?

 

It should be achievieable with adding event listener.

 

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
LEGEND ,
Feb 05, 2025 Feb 05, 2025
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
Engaged ,
Feb 05, 2025 Feb 05, 2025

Hi @dublove 

var myDocument = app.activeDocument;
var myFileName = myDocument.name.replace(/\.indd$/, ''); // Remove the .indd extension
var myDate = new Date();
var myYear = myDate.getFullYear();
var myMonth = ("0" + (myDate.getMonth() + 1)).slice(-2); // Add leading zero
var myDay = ("0" + myDate.getDate()).slice(-2); // Add leading zero
var myFormattedDate = myYear + "-" + myMonth + "-" + myDay;
var myPDFFile = new File(myDocument.filePath + "/" + myFormattedDate + "-" + myFileName + ".pdf");

var myPDFExportPreset = app.pdfExportPresets.item("[High Quality Print]"); // You can change the preset if needed
myDocument.exportFile(ExportFormat.PDF_TYPE, myPDFFile, false, myPDFExportPreset);
Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.
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
Guide ,
Feb 06, 2025 Feb 06, 2025

dublove_0-1738835035037.jpeg

I can't seem to set the export option.

Third party scripts should be difficult to implement.

Hoping that Adobe will add official functionality.

 

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
LEGEND ,
Feb 06, 2025 Feb 06, 2025

@dublove

 

I think there is something wrong with the name of the PDF export profile you've entered?

 

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
Guide ,
Feb 06, 2025 Feb 06, 2025

Thank you very much

Sorry ,sorry ,It's export PDF, I wrote import by mistake.

I know how to do it, I think I've seen who seems to have written scripts for exporting PDF interfaces.
Might be able to write this current script with that one.

 

I use a bit too many templates and sometimes I need to modify them temporarily.

Directly with the script export, can not temporarily modify the template.
Can you automatically modify the name when exporting?
Then only call the ID software comes with the interface to export PDF?

 

dublove_0-1738857970585.jpeg

 

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
Engaged ,
Feb 06, 2025 Feb 06, 2025

Yes, you're correct!

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.
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
Engaged ,
Feb 06, 2025 Feb 06, 2025

I can modify the script to allow selecting the preset through a small GUI and let you know.

 

 

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.
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
Guide ,
Feb 06, 2025 Feb 06, 2025

Very much looking forward to it.
Thanks.

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
Engaged ,
Feb 07, 2025 Feb 07, 2025
var myDocument = app.activeDocument;
var myFileName = myDocument.name.replace(/\.indd$/, ''); // Remove the .indd extension
var myDate = new Date();
var myYear = myDate.getFullYear();
var myMonth = ("0" + (myDate.getMonth() + 1)).slice(-2); // Add leading zero
var myDay = ("0" + myDate.getDate()).slice(-2); // Add leading zero
var myFormattedDate = myYear + "-" + myMonth + "-" + myDay;
var myPDFFile = new File(myDocument.filePath + "/" + myFormattedDate + "-" + myFileName + ".pdf");

// Create a dialog for selecting the PDF export preset
var myDialog = new Window('dialog', 'Select PDF Export Preset');
myDialog.orientation = 'column';
myDialog.alignChildren = 'left';

var myDropdown = myDialog.add('dropdownlist', undefined, app.pdfExportPresets.everyItem().name);
myDropdown.selection = 0;

var myButtonGroup = myDialog.add('group');
myButtonGroup.orientation = 'row';
myButtonGroup.add('button', undefined, 'OK', {name: 'ok'});
myButtonGroup.add('button', undefined, 'Cancel', {name: 'cancel'});

if (myDialog.show() == 1) {
    var myPDFExportPreset = app.pdfExportPresets.item(myDropdown.selection.text);
    myDocument.exportFile(ExportFormat.PDF_TYPE, myPDFFile, false, myPDFExportPreset);
} else {
    alert('Export canceled');
}
Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.
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
Guide ,
Feb 07, 2025 Feb 07, 2025

Thank you very much, it runs great.

Just that sometimes the original PDF file is already open and it prompts an error.
There can be a prompt “PDFfile is opening”

 

Am I correct in this modification?

 

 

try{
if (myDialog.show() == 1) {
    var myPDFExportPreset = app.pdfExportPresets.item(myDropdown.selection.text);
    myDocument.exportFile(ExportFormat.PDF_TYPE, myPDFFile, false, myPDFExportPreset);
} else {
    alert('Export canceled');
}
}
catch (e){alert ("PDFfile is opening……")}

 

 

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
Guide ,
Feb 09, 2025 Feb 09, 2025

How to determine the PDF file already exists?
For example:
if  "2025-02-08-myfile.pdf"  already exists, can it be saved as
2025-02-08-02-myfile.pdf
Thank you.

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
LEGEND ,
Feb 09, 2025 Feb 09, 2025
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
Guide ,
May 23, 2025 May 23, 2025

Hi @Anantha Prabu G 

Can you set the export range.
Right now it will only use the page number range that was set during the last manual export.

Or it would be nice to be able to export all page numbers by default.

Thank you

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
Guide ,
Jun 17, 2025 Jun 17, 2025
LATEST

Hi @m1b 

Help look at this.
Can you add a page number setting? 
Right now it only executes the last setting, and sometimes it will only export 1 page if you're not paying attention.

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