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

Scripting help to insert date in file name

New Here ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

Using InD 15.1.3, my client likes the date to be part of the file name and he likes it in a specific format: 06.09.21

 

Is there a way to program a shortcut key that will insert the current date in that format when naming/saving a file in InDesign?  I do this 100 times a day.

 

Thank you!

TOPICS
How to , Scripting

Views

334

Translate

Translate

Report

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

Community Expert , Jun 10, 2021 Jun 10, 2021

HI,

Try following snippet to save the file that will append the date in the end.

var dateObj = new Date();
var year = dateObj.getFullYear().toString().substr(-2);
var month = ("0" + (dateObj.getMonth() + 1)).slice(-2);
var date = ("0" + dateObj.getDate()).slice(-2);
var _formattedDate = month + "." + date + "." + year;
var fileName = "Test_" + _formattedDate + ".indd";
var file = app.activeDocument.save(File(Folder.desktop + "/" + fileName));

 

Votes

Translate

Translate
Community Expert ,
Jun 10, 2021 Jun 10, 2021

Copy link to clipboard

Copied

HI,

Try following snippet to save the file that will append the date in the end.

var dateObj = new Date();
var year = dateObj.getFullYear().toString().substr(-2);
var month = ("0" + (dateObj.getMonth() + 1)).slice(-2);
var date = ("0" + dateObj.getDate()).slice(-2);
var _formattedDate = month + "." + date + "." + year;
var fileName = "Test_" + _formattedDate + ".indd";
var file = app.activeDocument.save(File(Folder.desktop + "/" + fileName));

 

Best regards

Votes

Translate

Translate

Report

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
New Here ,
Sep 05, 2023 Sep 05, 2023

Copy link to clipboard

Copied

Hi! I'd like to try this but I don't know where to put the script once I've compiled it in Script Editor so that it is active when I go to save a file. What folder does it belong in?

Votes

Translate

Translate

Report

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
Community Expert ,
Sep 05, 2023 Sep 05, 2023

Copy link to clipboard

Copied

LATEST

Votes

Translate

Translate

Report

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