Sarah, I think you are using the wrong variable name Filename, when it should be FileName, e.g., var CommunityType = FileName.slice(0,4) I changed these in your code and it works for me now. #target bridge if( BridgeTalk.appName == "bridge" ) { FT = MenuElement.create("command", "Convert FileName to Title", "at the end of Tools"); } FT.onSelect = function () { var thumbs = app.document.selections; if(!thumbs.length) return; if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript"); for(var a in thumbs){ var selectedFile = thumbs.spec; var FileName = decodeURI(selectedFile.name).slice(0,7) var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE); var myXmp = myXmpFile.getXMP(); var CommunityType = FileName.slice(0,4) switch (CommunityType) { case 'SCRB': CommunityType = "Northern Coastal Scrub:"; break; case 'CLOW': CommunityType = "Coast Live Oak Woodlands:" } var Plot = FileName.slice(5,6) var Transect = FileName.slice(7) var NewFileName = CommunityType + " Plot " + Plot + ", Transect " + Transect var Desc=[]; var count = myXmp.countArrayItems(XMPConst.NS_DC, "title"); for(var i = 1;i <= count;i++){ Desc.push(myXmp.getArrayItem(XMPConst.NS_DC, "title", i)); } Desc=Desc.toString() + " " + NewFileName; myXmp.deleteProperty(XMPConst.NS_DC, "title"); myXmp.appendArrayItem(XMPConst.NS_DC, "title", Desc, 0, XMPConst.ALIAS_TO_ALT_TEXT); myXmp.setQualifier(XMPConst.NS_DC, "title[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default"); if (myXmpFile.canPutXMP(myXmp)) { myXmpFile.putXMP(myXmp); myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY); } } }
... View more