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

Removing seconds from XMPDateTime

Explorer ,
Jan 24, 2018 Jan 24, 2018

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.

TOPICS
Scripting

Views

616

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
Guide ,
Jan 24, 2018 Jan 24, 2018

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)));

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
Enthusiast ,
Feb 05, 2018 Feb 05, 2018

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);

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

Copy link to clipboard

Copied

LATEST

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.

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