read the xmp CreatedDate add 2 years to it and write the result into another custom xmp

Post Reply
McCannManchester
Newbie
Posts: 16
Joined: Tue Sep 18, 2012 5:01 pm

read the xmp CreatedDate add 2 years to it and write the result into another custom xmp

Post by McCannManchester »

Hi hope someone can help with this problem



Take an incoming image read the xmp:CreateDate add 2 years to the CreatedDate write the result to a custom xmp field.



Ok i've already created a work flow that reads/writes to custom xmp fields, this problem i think needs a script, as just writing a static value is straight forward but the value need to be calculated.



Why you ask well we are looking to add and expiry date.
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

read the xmp CreatedDate add 2 years to it and write the result into another custom xmp

Post by dkelly »

var theCreateDate = new Date();

var theXmp = job.getDataset("Xmp");

if (theXmp != null) {

theCreateDate = theXmp.getDate( "xmp:CreateDate" , null );

theCreateDate.setYear(theCreateDate.getYear()+2);

}

theCreateDate.toString();

McCannManchester
Newbie
Posts: 16
Joined: Tue Sep 18, 2012 5:01 pm

read the xmp CreatedDate add 2 years to it and write the result into another custom xmp

Post by McCannManchester »

hi and thanks for the script, as you can see below it has embedded a date into the wxmv:valid_to_date only its the time and date of when it went through the workflow?







just to check i've done thinks right, using the 'XMP inject' tool i've chosen the area to which i want the value writing to in the 'XMP location path' in the 'New value' area i've chosen to 'Define script expression' and pasted the script.



As you can see the 'CreateDate' of the image is 2013-12-18T16:48:51.



Any ideas



Thanks
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

read the xmp CreatedDate add 2 years to it and write the result into another custom xmp

Post by dkelly »

It appears that the script did not find any XMP metadata for the job. Does your flow have a "XMP pickup" element to read the job's embedded XMP metadata in to a Switch dataset?
McCannManchester
Newbie
Posts: 16
Joined: Tue Sep 18, 2012 5:01 pm

read the xmp CreatedDate add 2 years to it and write the result into another custom xmp

Post by McCannManchester »

Thanks for your help i hadn't quite got the workflow right it now works like a dream, thanks again
Post Reply