Replace "Description" metadata with string script.
I'm working with a script to assign a string (in this case, the color of the product in the image) to the description field in the image's metadata. It would save time on the layout side by taking advantage of InDesign's live caption capabilities. I'm processing the selections with a for loop, and the script will either work, or return an error: "XMP Exception: LFA_Close: FSCloseFork failure" I can't reliably duplicate the error, sometimes I can process all the images, and other times it errors out after the first one. Does anyone have a description of the error, and/or any suggestions on how to fix it?
Using Bridge CS5
-S
function writecolortodescription(colorway,myimage){
// adds the colorway name to the "Description" field in the metadata to take advantage of InDesign CS5's live caption features.
// borrowed heavily from a script by Paul Riggott (adobe forums)
loadXMPLib();
var thumb = new Thumbnail(myimage);
if(thumb.hasMetadata){
var selectedFile = thumb.spec;
var myXmpFile = new XMPFile(selectedFile.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",colorway);
if (myXmpFile.canPutXMP(myXmp)) {
myXmpFile.putXMP(myXmp);
myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
}
}
unloadXMPLib();
}
function loadXMPLib(){
if (ExternalObject.AdobeXMPScript == undefined) {
ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
}
}
function unloadXMPLib(){
if( ExternalObject.AdobeXMPScript ) {
try{
ExternalObject.AdobeXMPScript.unload();
ExternalObject.AdobeXMPScript = undefined;
}catch (e){ }
}
}
