Hi,
We have a droplet opening images, changing their colour profiles, flaterning them, etc. one by one.
This droplet, mainly using a signle script, will eventually change as well the filenames.
I would like to store the filename of each image in its "description metadata".
I've seen it was douable in Bridge as per below, can the same be done in Photoshop cs6?
- #target bridge
- if( BridgeTalk.appName == "bridge" ) {
- FT = MenuElement.create("command", "Add FileName to Description", "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[a].spec;
- var FileName = decodeURI(selectedFile.name).replace(/\.[^\.]+$/, '')
- var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
- var myXmp = myXmpFile.getXMP();
- var Desc=[];
- var count = myXmp.countArrayItems(XMPConst.NS_DC, "description");
- for(var i = 1;i <= count;i++){
- Desc.push(myXmp.getArrayItem(XMPConst.NS_DC, "description", i));
- }
- Desc=Desc.toString() + " " + FileName;
- myXmp.deleteProperty(XMPConst.NS_DC, "description");
- myXmp.appendArrayItem(XMPConst.NS_DC, "description", Desc, 0, XMPConst.ALIAS_TO_ALT_TEXT);
- myXmp.setQualifier(XMPConst.NS_DC, "description[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");
- if (myXmpFile.canPutXMP(myXmp)) {
- myXmpFile.putXMP(myXmp);
- myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
- }
- }
- }