This will write the selected documents description field to the console in the ExtendScript Toolkit.
You will have to be more precise on what you want to do with the string to be able to give an example.
#target bridge
loadXMPLibrary();
for(var a in app.document.selections){
var thumb = app.document.selections;
if(thumb.hasMetadata){
var selectedFile = thumb.spec;
var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ);
var myXmp = myXmpFile.getXMP();
for(var i = 1;i <= items;i++){
var Desc = ArrayItems(XMPConst.NS_DC, "description");
$.writeln(Desc);
}
}
unloadXMPLibrary();
}
function loadXMPLibrary(){
if ( !ExternalObject.AdobeXMPScript ){
try{
ExternalObject.AdobeXMPScript = new ExternalObject
( 'lib:AdobeXMPScript' );
}catch (e){
alert( ErrStrs.XMPLIB );
return false;
}
}
return true;
}
function unloadXMPLibrary(){
if( ExternalObject.AdobeXMPScript ) {
try{
ExternalObject.AdobeXMPScript.unload();
ExternalObject.AdobeXMPScript = undefined;
}catch (e){
alert( ErrStrs.XMPLIB );
}
}
}
function ArrayItems(ns, prop){
arrItem='';
var items = myXmp.countArrayItems(ns, prop);
if(items > 0){
for(var i = 1;i <= items;i++){
arrItem += myXmp.getArrayItem(XMPConst.NS_DC, prop, i);
}
}
return arrItem;
}