OnDownload File name with variable

Hello,

When downloading a file with onDownload, I use executeScript_Sandbox with this forumal to get the date :
var d=new Date(); return d.getDate()+’-’+((d.getMonth()+1))+’-’+d.getFullYear();

It work fine, but :
• Is it also possible to keep the original file name and simply add the date in front of the file name?
• And is it possible to change the date format to (I only need month + year) : January 2020 - original file name

Thanks for your help :slight_smile:

var d=new Date(); var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; return (months[d.getMonth()])+' '+d.getFullYear();

That will return just the month and year: February 2020

OnDownload | ${datevariable} filename | true

Result: February 2020 filename

Hello,

Thanks for your help.
Is it possible to replace “filename” with the original file name and only add the variable date before the name of the original file name ?

Because when using “filename”, once downloaded, my file name is eg : “february 2020 filename” and not the original file name.

Last question, I would like to get the last month date (month -1), i see that in the help page but I don’t really know how to use inside your formula ?

Thanks again !

This will return the previous month:
var d=new Date(); var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; return (months[d.getMonth()-1])+' '+d.getFullYear();

To keep the original filename I would use XRun and then change it w/ PowerShell code using Rename-Item. You could also turn on “Ask where to save each file before downloading” and then use XCommands to type the date before the filename and then click save.

Ok, will try this, thanks a lot !