#target bridge
if( BridgeTalk.appName == "bridge" ) {
folderTokeys = MenuElement.create("command", "Add Filename to Keywords", "at the end of Tools");
}
folderTokeys.onSelect = function () {
var thumbs = app.document.selections;
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
for(var a =0;a<thumbs.length;a++){
var selectedFile = new Thumbnail(thumbs[a]);
var Name = decodeURI(selectedFile.spec.name).replace(/\.[^\.]+$/, '');
app.synchronousMode = true;
var xmp = new XMPMeta(selectedFile.synchronousMetadata.serialize());
xmp.appendArrayItem(XMPConst.NS_DC, "subject", Name, 0,XMPConst.PROP_IS_ARRAY);
var newPacket = xmp.serialize(XMPConst.SERIALIZE_USE_COMPACT_FORMAT);
selectedFile.metadata = new Metadata(newPacket);
}
ExternalObject.AdobeXMPScript.unload();
ExternalObject.AdobeXMPScript = undefined;
};