Copy link to clipboard
Copied
I'm trying to build a script in ExtendScript Toolkit CC that will modify the date metadata for files in Bridge. I'm using "var d = new XMPDateTime(new Date())" to get the full date value. How can I removed the seconds in the value and get this value instead --> YYYY MM DD HM. I've searched the Adobe site and forums and could not find an answer.
Copy link to clipboard
Copied
Here is an example for ESTK run with target Bridge..
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var now = new Date();
$.writeln(now);
var seconds = now.getSeconds();
var mSeconds = now.getMilliseconds();
now = now.getTime() - ((seconds * 1000)+mSeconds);
$.writeln(new Date(now));
$.writeln(new XMPDateTime(new Date(now)));
Copy link to clipboard
Copied
You can use RegExp after convert the XMPDateTime to a string:
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var d = new XMPDateTime(new Date())
var result = d.toString().match(/\d{4}\-\d{2}\-\d{2}\T\d{2}\:\d{2}/).toString().replace(/\-|\T|\:/g,' ')
$.writeln(result);
Copy link to clipboard
Copied
I think the OP requires a new XMPDateTime to set the date Pedro, so this would fail.
We may never know as the OP has not responded.