Copy link to clipboard
Copied
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;
}
}
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
In that case you would have to use different code, you should be able to modify the code to suit from here...
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more