Skip to main content
Feeltheday
Participating Frequently
December 2, 2015
Answered

Edit IPTC Extension metadata in Photoshop script

  • December 2, 2015
  • 1 reply
  • 1098 views

Hi,

I'm using a droplet which based on a script will rename my pictures.

I would like to save the original file name in the Supplier's Image ID metadata if possible.

Can I do that only in Photoshop without using Bridge?

I've tried to do a couple of things but I'm always failing.

For now I was using this:

function saveJpeg(docRef, targetFolder){

  var theName = getNameWithoutExt(docRef);

  var doc = activeDocument; 

  doc.info.caption += ">>>> ORIGINAL NAME: ";

  doc.info.caption += doc.name;   

  var desiredName = truncate(theName.replace(/[^\w\s\d\(\)~_~-]/gi, ''),50);

  var thePath = app.activeDocument.path;

  var theFile = new File (targetFolder + "/" + desiredName + ".jpg");

BLA BLA BLA

Thanks for your help, still digging in the meanwhile.

This topic has been closed for replies.
Correct answer SuperMerlin

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

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

xmp.setProperty("http://ns.useplus.org/ldf/xmp/1.0/","ImageSupplierImageID", activeDocument.name);

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

1 reply

SuperMerlin
SuperMerlinCorrect answer
Inspiring
December 2, 2015

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

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

xmp.setProperty("http://ns.useplus.org/ldf/xmp/1.0/","ImageSupplierImageID", activeDocument.name);

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

Feeltheday
Participating Frequently
December 6, 2015

Thank you it works perfectly like a charm