Quantcast
Channel: Adobe Community : Popular Discussions - Photoshop Scripting
Viewing all articles
Browse latest Browse all 12244

Add filename to description

$
0
0

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?

  1. #target bridge    
  2.    if( BridgeTalk.appName == "bridge" ) {   
  3. FT = MenuElement.create("command", "Add FileName to Description", "at the end of Tools"); 
  4. FT.onSelect = function () {  
  5. var thumbs = app.document.selections;  
  6. if(!thumbs.length) return; 
  7. if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript"); 
  8. for(var a in thumbs){ 
  9. var selectedFile = thumbs[a].spec;     
  10. var FileName = decodeURI(selectedFile.name).replace(/\.[^\.]+$/, '') 
  11.       var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);  
  12.   var myXmp = myXmpFile.getXMP(); 
  13. var Desc=[]; 
  14. var count =  myXmp.countArrayItems(XMPConst.NS_DC, "description"); 
  15. for(var i = 1;i <= count;i++){ 
  16. Desc.push(myXmp.getArrayItem(XMPConst.NS_DC, "description", i)); 
  17.     } 
  18. Desc=Desc.toString() + " " + FileName; 
  19.         myXmp.deleteProperty(XMPConst.NS_DC, "description"); 
  20.         myXmp.appendArrayItem(XMPConst.NS_DC, "description", Desc, 0, XMPConst.ALIAS_TO_ALT_TEXT); 
  21.         myXmp.setQualifier(XMPConst.NS_DC, "description[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default"); 
  22.         if (myXmpFile.canPutXMP(myXmp)) {  
  23.         myXmpFile.putXMP(myXmp); 
  24.          myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);  
  25.          }  
  26.     } 

Viewing all articles
Browse latest Browse all 12244

Trending Articles