Skip to main content
Participant
December 17, 2013
Answered

Script : how to copy xmpDM:logComment into DC:Description ?

  • December 17, 2013
  • 1 reply
  • 961 views

Hi !

I'm fiddling with this code to copy the xmpDM:logComment field into the DC:Description field and each time i run it, it fails saying an error relating to : Unregistred Namespace.

Code comes from here : http://forums.adobe.com/message/3847726

#target bridge  

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

descToTitle = MenuElement.create("command", "Log Comment to Description", "at the end of Tools");

}

descToTitle.onSelect = function () {

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

var thumb = app.document.selections;

    for(var s in thumb){

if(thumb.hasMetadata){

        var selectedFile = thumb.spec;

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

  var myXmp = myXmpFile.getXMP();

         var LogComment = getProperty.(XMPConst.NS_DM, "logComment");

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

        myXmp.appendArrayItem(XMPConst.NS_DC, "description", LogComment, 0, XMPConst.ALIAS_TO_ALT_TEXT);

        myXmp.setQualifier(XMPConst.NS_DC, "description[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");

    }

function getArrayItems(ns, prop){

var arrItem=[];

try{

var items = myXmp.countArrayItems(ns, prop);

for(var i = 1;i <= items;i++){

arrItem.push(myXmp.getArrayItem(ns, prop, i));

     }

return arrItem;

}catch(e){alert(e +" Line: "+ e.line);}

}

        if (myXmpFile.canPutXMP(myXmp)) {

        myXmpFile.putXMP(myXmp);

        myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);

         } else {

  xmpFile.closeFile();

        }

    }

}

Can anyone point me where my error is ?

thx!

This topic has been closed for replies.
Correct answer I have gone

It should be getProperty, also it requires a reference to the metadata, try this.

var LogComment = myXmp.getProperty(XMPConst.NS_DM, "logComment");

1 reply

I have goneCorrect answer
Inspiring
December 17, 2013

It should be getProperty, also it requires a reference to the metadata, try this.

var LogComment = myXmp.getProperty(XMPConst.NS_DM, "logComment");

Kay_RozenAuthor
Participant
December 18, 2013

Thx ! That was it.