Skip to main content
Participant
March 14, 2008
Question

copy keywords into description-field

  • March 14, 2008
  • 6 replies
  • 1880 views
Hello,

I have to work on many pictures so i don't want to do every step for every picture. I have no experience with scription so i ask you.

I'm searching for a script (or somthing else) that copies the keywords of one file into the description-field of the same file automaticly.

Yours Robin from Germany
This topic has been closed for replies.

6 replies

November 19, 2009

Hello,

I am hoping someone will be able to help me.  I am looking for a script that will take information that is typed into a custom metadat panel in Bridge CS4 and and automatically populate a designated IPTC field with the same information.

For example, I would like the information in the "Program Title" field of our custom panel to automatocally populate in the "Headline" field of the IPTC panel.

I am not as well versed in scripting as I would like to be and did manage to get our custom panel and an export script up an running but I still feel like I am drowning when I read this stuff....  I have found the following script in the forums and it seems like it should work if I can figure what needs to be changed and the repeat the changes for each field.

Code:

#target bridge

addNametoMeta = {};

addNametoMeta.execute = function(){   
  var sels = app.document.selections;  
  for (var i = 0; i < sels.length; i++){

var md = sels.synchronousMetadata;
    md.namespace = "http://ns.adobe.com/photoshop/1.0/";
    md.Source = sels.name;
  }
}

// this script only works in bridge
if (BridgeTalk.appName == "bridge"){

  var menu = MenuElement.create( "command", "Save Filename in Metadata", "at the end of Tools");
  menu.onSelect = addNametoMeta.execute;
}

Can anyone help?

Thanks,

Robin

Paul Riggott
Inspiring
November 20, 2009

This should get you started...

#target bridge
addDetailToHeadline();
function addDetailToHeadline(){
if( xmpLib == undefined ) {
      if( Folder.fs == "Windows" )
      {var pathToLib = Folder.startup.fsName + "/AdobeXMPScript.dll";}
      else {var pathToLib = Folder.startup.fsName + "/AdobeXMPScript.framework";}
      var libfile = new File( pathToLib );
      var xmpLib = new ExternalObject("lib:" + pathToLib );
}
/////////// You will need to get your panel details into this sring
var str = "Photo ";
/////////////////////////////////////////////////
var sels = app.document.selections;
for(var a =0; a<sels.length;a++){
var thumb = sels;
   if(thumb.hasMetadata && sels
.type == "file"){
      var selectedFile = thumb.spec;   
      var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);      
      var myXmp = myXmpFile.getXMP();      
      myXmp.deleteProperty(XMPConst.NS_PHOTOSHOP, "Headline");
      myXmp.setProperty(XMPConst.NS_PHOTOSHOP, "Headline", str);
      if (myXmpFile.canPutXMP(myXmp)) {
    myXmpFile.putXMP(myXmp);
         myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
         }
      }
   }
}

Participating Frequently
November 30, 2008
Thanks really!
Good Luck.
______
My Si tes
Participant
April 16, 2008
Thank you!!
It works perfect.
Paul Riggott
Inspiring
April 16, 2008
I have just done a quick test and this seems to work.<br />Copies the keywords to the description field.<br />Make sure that you do a test first!<br />NB:Folder.userData Adobe/XMP/Metadata Templates, folder must exist.<br />Paul<br /><br />#target bridge<br />var items = app.document.selections; <br /> for (var i = 0; i < items.length; ++i) { <br /> var item = items; <br />var m = item.synchronousMetadata; <br />m.namespace = "http://ns.adobe.com/photoshop/1.0/"; <br />var Des = m.read("http://purl.org/dc/elements/1.1/","dc:description");<br />var Keywords = m.Keywords;<br />if(Des.length >0) {<br /> var Description = Des + ";"+Keywords;<br /> }else{<br /> var Description = Keywords;<br /> }<br /> KeywordsToDesc(m, Description);<br /> }; <br /><br />function KeywordsToDesc(metadata, Description) <br />{ <br />var strTmpl = "TempTmpl"; <br />var strUser = Folder.userData.absoluteURI; <br />var filTmpl = new File(strUser + "/Adobe/XMP/Metadata Templates/" + strTmpl + ".xmp"); <br />var fResult = false; <br />try <br />{ if (filTmpl.exists) <br />filTmpl.remove(); <br />fResult = filTmpl.open("w"); <br />if (fResult) <br />// CS3<br />{ filTmpl.writeln("<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"Adobe XMP Core 4.1-c036 46.276720, Mon Feb 19 2007 22:40:08 \">");<br />//CS2<br />//{ filTmpl.writeln("<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"3.1.2-113\">"); <br />filTmpl.writeln(" <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">"); <br />filTmpl.writeln(" <rdf:Description rdf:about=\"\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">"); <br />filTmpl.writeln("<dc:description>");<br />filTmpl.writeln("<rdf:Alt>");<br />filTmpl.writeln("<rdf:li xml:lang=\"x-default\">"+Description+"</rdf:li>");<br />filTmpl.writeln("</rdf:Alt>");<br />filTmpl.writeln("</dc:description>");<br />filTmpl.writeln(" </rdf:Description>"); <br />filTmpl.writeln(" </rdf:RDF>"); <br />filTmpl.writeln("</x:xmpmeta>"); <br />fResult = filTmpl.close(); <br />metadata.applyMetadataTemplate(strTmpl, "replace"); <br />filTmpl.remove(); <br />} } <br />catch(e) <br />{ fResult = false; } <br />return fResult; <br />};
Known Participant
April 9, 2008
I'm looking for the same thing - ideally a complete copy of all metadata from one file to one or many others via a simple interface eg copy and paste special.

Metadata templates are too inflexible for my application.
Participant
March 28, 2008
Does nobody know how to do that?