Skip to main content
Known Participant
October 13, 2011
Question

description in metadata in cs5

  • October 13, 2011
  • 1 reply
  • 909 views

Hi,

Here is a script that output the keywords in the keywords metadata but dont do the same for the description part. (prompt)

addNametoMeta.execute = function(){

var shiftRange = prompt("test", 10);

var descript = prompt("Description", 10);

  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/";

    var Name = decodeURI(sels.name).replace(/\.[^\.]+$/, '');

    md.Keywords = md.Keywords + ";" + shiftRange  + ";" +  Name;

md.description[0]  = md.description[0]  + shiftRange +  descript;

  }

}

This topic has been closed for replies.

1 reply

Paul Riggott
Inspiring
October 13, 2011

With the description field it needs to be empty before you can put data into it.

md.description[0] = md.description[0] + shiftRange + descript; // This won't work as data exists

You could try doing the following...

var desc = md.description[0];

md.description[0] = '';

md.description[0] = desc + shiftRange + descript;

J4e8a16nAuthor
Known Participant
October 20, 2011

Sorry.  It does not work.

#target bridge
addNametoMeta = {};

addNametoMeta.execute = function(){
var shiftRange = prompt("test", 10);
var descript = prompt("Description", 10);
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/";
  var Name = decodeURI(sels.name).replace(/\.[^\.]+$/, '');
  md.Keywords = md.Keywords + ";" + shiftRange  + ";" +  Name;
  var desc = md.description[0];
  md.description[0] = '';
  md.description[0] = desc + shiftRange + descript;
}
}

Thanks,

JP

Paul Riggott
Inspiring
October 20, 2011

In that case you would have to use different code, you should be able to modify the code to suit from here...

http://forums.adobe.com/thread/887960?tstart=0