Skip to main content
Known Participant
January 12, 2012
Answered

Combining data from iptc fields

  • January 12, 2012
  • 1 reply
  • 1892 views

Hello group. Happy New Year.

I'm looking for a script which would perform an action of copying data from the city, state/prov and country fields and adding that data to the description field. I still wish to retain the content in the description field. My stock agency is requesting this be done in order to create a more complete picture caption for web display.

Hoping the list can help! Thanks

Don

This topic has been closed for replies.
Correct answer Paul Riggott

Happy new year Don, hope you have a good one!

Please try this...

#target bridge  

if( BridgeTalk.appName == "bridge" ) { 

combineFields = MenuElement.create("command", "Details to Description", "at the end of Tools","cft2012");

}

combineFields.onSelect = function () {

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

var sels = app.document.selections;

for(var z in sels){

var t = new Thumbnail(sels);   

var md = t.synchronousMetadata

var Desc = md.read("http://purl.org/dc/elements/1.1/",  "dc:description");

var City = md.read("http://ns.adobe.com/photoshop/1.0/",  "City");

var Country = md.read("http://ns.adobe.com/photoshop/1.0/",  "Country");

var Region =  md.read("http://ns.adobe.com/photoshop/1.0/",  "State");

var DescAll = Desc + "\r" +City + "\r" + Region +"\r" + Country;   

var myXmpFile = new XMPFile( t.spec.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);

var myXmp = myXmpFile.getXMP();

myXmp.deleteProperty(XMPConst.NS_DC, "description");

myXmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", DescAll );

if (myXmpFile.canPutXMP(myXmp)) {

        myXmpFile.putXMP(myXmp);

         myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);

        }

    }

}

1 reply

Paul Riggott
Paul RiggottCorrect answer
Inspiring
January 12, 2012

Happy new year Don, hope you have a good one!

Please try this...

#target bridge  

if( BridgeTalk.appName == "bridge" ) { 

combineFields = MenuElement.create("command", "Details to Description", "at the end of Tools","cft2012");

}

combineFields.onSelect = function () {

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

var sels = app.document.selections;

for(var z in sels){

var t = new Thumbnail(sels);   

var md = t.synchronousMetadata

var Desc = md.read("http://purl.org/dc/elements/1.1/",  "dc:description");

var City = md.read("http://ns.adobe.com/photoshop/1.0/",  "City");

var Country = md.read("http://ns.adobe.com/photoshop/1.0/",  "Country");

var Region =  md.read("http://ns.adobe.com/photoshop/1.0/",  "State");

var DescAll = Desc + "\r" +City + "\r" + Region +"\r" + Country;   

var myXmpFile = new XMPFile( t.spec.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);

var myXmp = myXmpFile.getXMP();

myXmp.deleteProperty(XMPConst.NS_DC, "description");

myXmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", DescAll );

if (myXmpFile.canPutXMP(myXmp)) {

        myXmpFile.putXMP(myXmp);

         myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);

        }

    }

}

Known Participant
January 12, 2012

Hi Paul

Many thanks!

Please bear with me regarding getting this script going. I copied your code and pasted it into ExtendScript Toolkit in Adobe utilities CS5. I gave it a name and saved it to my Bridge Scripts folder. When I restarted Bridge i was asked if I wished to enable this script, so things looked good so far.

But when I tried it on a nef file which contained info in the relevant fields nothing happened, so I don't know whether there is a bug in the script or whether I missed doing something trying to apply it. I clicked on a file and then I clicked on the script which now appears in the Tools window, but the info in the Description field remained the same.

What am I missing?

Hope 2012 is off to a great start for you!

Don