Can someone give some advice on setting metadata values within Bridge using javascript? The examples all seem to deal with Text types like the following:
md = tn.metadata;
md.namespace = "
http://ns.adobe.com/photoshop/1.0/";
md.Author = "Jane Smith";
But when trying to set other types, like the "caption" (which gets mapped to "
http://purl.org/dc/elements/1.1/description"), the script will throw an exception.
md.namespace = "
http://purl.org/dc/elements/1.1/";
md.description = "New Caption"
-- Uncaught exception description --
I'm thinking this is probably because dc:description is defined as a "Lang Alt" type in the xmp specification which in turn is defined as:
"Language alternatives are a form of rdf:Alt array, referred to as the Lang Alt type. In this
example, each array item is a simple text value; the value has a property qualifier, specified as
the property xml:lang, giving the language of that value. "
But no matter how I try accessing this object (there is no "reflect" available on metadata objects), I can't seem to change the string value.
Any ideas would be much appreciated.
-----
On another topic, would it be possible for someone to post the Export Metadata Script here in this forum for those of us who don't have access to the partners site? Here's is my working go at an export metadata script for Bridge that simply prints to the debugger. It's basically a quick hack of some of the routines in AdobeLibrary3.jsx which it also needs in order to run.
Thanks,
Bruce
#target bridge
if( BridgeTalk.appName == "bridge" ) {
DebugMeta = {};
DebugMeta.execute = function() {
// print out the metadata for the selected thumbnails
var sels = app.document.selections;
for (var i = 0; i < sels.length; i++) {
var t = sels
;
var m = t.synchronousMetadata;
// loop through all possible elements (properties)
var elements = MdNs.elements.keyList;
for (var j = 0; j < elements.length; j++) {
var el = MdNs.elements.get(elements);
if (el.scriptAccessible) {
try {
// print the value (and the mapping if it's redirected)
var val = el.getValue(m);
if ( isValidReference( val )
&& ( val.length > 0 )
&& ( trim( val ) != null ) ) {
$.write(el.handle + " = " + val);
if (el.redirected) {
$.writeln(" (" + el.redirectElement.ns.ns + el.redirectElement.property + ")");
} else {
$.writeln();
}
}
} catch (e) {
}
}
}
}
}
// setup menu
var myMenu = createMenu( "command", "DebugMeta",
"-at the end of Tools-", "tools/DebugMeta", DebugMeta.execute);
var contextMenu = createMenu ( "command", "DebugMeta",
"-at the end of Thumbnail-", "thumbnail/DebugMeta", DebugMeta.execute);
}