Skip to main content
Known Participant
October 21, 2016
Question

Changing the creation date

  • October 21, 2016
  • 3 replies
  • 6557 views

Hello,

I'm writing a script which should change the metadata of a tif image.

This works fine

img.info.author = "Me";

img.info.city = "London";

I also want to change the creation date and according to Adobe Photoshop JavaScript Reference, the date should be in format "YYYYMMDD", but this doesn't work:

img.info.creationDate = '20000101';

I also tried different formats to no avail too:

img.info.creationDate = '2000/01/01';

img.info.creationDate = '01012000';

img.info.creationDate = '01/01/2000';

Plz help.

Thanks.

This topic has been closed for replies.

3 replies

ZeetoAuthor
Known Participant
October 23, 2016

I don't know what I'm doing wrong.

I literally copied and pasted your script and it didn't change the Created Date.

When I open the file in Bridge, I can see the original date, when I open the file in Photoshop and open "File Info" the Created Date in "Description" tag is still set to original date. None of the dates in "Raw Data" is changed to "2010/01/24" too.

If I intentionally define wrong string (for example '24012010') it doesn't change the Creation Date to undefined as well.

For some reason this Property behaves as it was Read-only.

DBarranca
Legend
October 23, 2016

Have you saved the file?

ZeetoAuthor
Known Participant
October 23, 2016

Hey DBarranca,

Yes I did. The new file has all the other properties set ok (like info.author, info.city, info.copyrighted and so on). Only the creation date remains as in original file - info.createDate just does nothing at all.

I'm not sure if SuperMerlins last answer suggests that there is a mistake in documentation?

I have CS6 documentation with the provided example and when I copy / paste the whole example the creationDate is not set.

Btw I'm on CS6 64 / Win 7

Thank you for participating.

ZeetoAuthor
Known Participant
October 23, 2016

Thank you for this solution, but I was looking for dom approach as per my example (sorry I should have specified).

I'm really stuck - the property "creationDate" according to documentation is Read-write, I don't have any problem with changing any other properties I want, but "creationDate".

I'm still looking for a solution, so any help would be highly appreciated.

Thanks

DBarranca
Legend
October 23, 2016

Actually, the following works for me (Mac, CC 2015.5)

app.activeDocument.info.creationDate = "20101024"

app.activeDocument.info.creationDate; // 20101024

If you input a wrong string, it returns undefined.

Davide

SuperMerlin
Inspiring
October 21, 2016

This is one way to do it...

if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

var newDate = "2008-06-10T02:43:23";

xmp = new XMPMeta( app.activeDocument.xmpMetadata.rawData );

if( xmp.doesPropertyExist(XMPConst.NS_PHOTOSHOP, "DateCreated" ) )  xmp.deleteProperty( XMPConst.NS_PHOTOSHOP, "DateCreated" );

xmp.setProperty( XMPConst.NS_PHOTOSHOP, "DateCreated" ,new XMPDateTime(newDate));

app.activeDocument.xmpMetadata.rawData = xmp.serialize();