Skip to main content
Participant
November 20, 2012
Question

Populating file description field with information from keywords field

  • November 20, 2012
  • 1 reply
  • 853 views

Hi i am new to using scripts and would really appreciate some help in automating the following. I use Photoshop CS6 and generally use the keywords i add to the file as the description as well. To do this i open individual raw files and copy and paste the keywords into the description field and save, prior to processing as jpg for web display. This is quite time consuming when dealing with large number of files. I have been trying to find a way to automate the process but haven't come across anything on the web. I did manage to get a partial solution using a recorded action and then batch processing in bridge, but that only adds the information from the first file used to generate the action.

Is there a way to do this with scripts for either the raw file or jpg file?

thanks

This topic has been closed for replies.

1 reply

Paul Riggott
Inspiring
November 20, 2012

This should copy the keywords to the description field on selected documents. It will not work on Raw files.

Raw files would need a different script and would have to know what type of raw files (nef,cr2,crw,mos,orf etc)

#target bridge  

   if( BridgeTalk.appName == "bridge" ) { 

descFromKeys = MenuElement.create("command", "Add Description from Keywords", "at the end of Tools");

}

descFromKeys.onSelect = function () {

if (ExternalObject.AdobeXMPScript == undefined)   ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

var sels = app.document.selections;

for(var t in sels){

      var selectedFile = sels.spec;   

      var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);      

      var myXmp = myXmpFile.getXMP();  

      Keywords = getArrayItems(XMPConst.NS_DC,'subject');

      myXmp.deleteProperty(XMPConst.NS_DC, "description");

      myXmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", Keywords);

      if (myXmpFile.canPutXMP(myXmp)) {

    myXmpFile.putXMP(myXmp);

         myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);

         }

function getArrayItems(ns, prop){

var arrItem=[];

try{

var items = myXmp.countArrayItems(ns, prop);

for(var i = 1;i <= items;i++){

arrItem.push(myXmp.getArrayItem(ns, prop, i));

}

return arrItem.toString();

}catch(e){alert(e +" Line: "+ e.line);}

    }

}

}


Yawkofi28Author
Participant
November 21, 2012

Thanks very much Paul. I also found your previous post on this and have followed the instuctions on there on how to install and run the script. However when i choose it and apply it to selected jpg files, nothing happens and the description field is still blank.

For raw, i mostly use cr2 format, but occassionally rw2 format. I can convert them to dng so if its more convenient to have one script for dng that would be fine?