Copy link to clipboard
Copied
Hi,
I am trying to create an Adobe Bridge 2018 script to "Prepend filename to the Description".
#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/";
var Name = decodeURI(sels.name).replace(/\.[^\.]+$/, '');
md.Caption = md.Caption + Name;
}
}
if (BridgeTalk.appName == "bridge"){
var menu = MenuElement.create( "command", "Prepend Filename to description", "at the end of Tools");
menu.onSelect = addNametoMeta.execute;
}
Have tried: md.Description = md.Description + Name;
Would like: md.Description = md.Description + " " + Name;
Any suggestions out there ????
You mean correct choise for description aka caption? If so then with Dublin Core it doesn't work. Caption is undocumented. There's description indeed in reference but as I don't work with Br scripting often I can not remind now did I ever used that.
Ah, your right… now I’m really confused!
Let me dig a little deeper!
EDIT: OK, so the script in the OP is adding the filename to the end/suffix (without a word space or other separator) of the existing DC:Description metadata.
The following code will pre
...Copy link to clipboard
Copied
Your code works. Description you used is incorrect. Caption included in original code is that keyword you are looking for
Copy link to clipboard
Copied
Hi Kukurykus
As you say stephend54917218 has a sample script that is targeting the Caption metadata (even though the script mentions description, that is obviously a mistake, perhaps inherited from altering another script that was originally targeting the description metadata).
If you wish to target the description metadata, then you need to use the correct namespace.
I don’t believe that the Photoshop NS http://ns.adobe.com/photoshop/1.0 is the correct choice for the description metadata. I believe that the script should be using the Dublin Core http://purl.org/dc/elements/1.1/ NS instead.
Copy link to clipboard
Copied
You mean correct choise for description aka caption? If so then with Dublin Core it doesn't work. Caption is undocumented. There is description indeed in reference but as I don't work with Br scripting often I can not remind now did I ever use that.
Copy link to clipboard
Copied
You mean correct choise for description aka caption? If so then with Dublin Core it doesn't work. Caption is undocumented. There's description indeed in reference but as I don't work with Br scripting often I can not remind now did I ever used that.
Ah, your right… now I’m really confused!
Let me dig a little deeper!
EDIT: OK, so the script in the OP is adding the filename to the end/suffix (without a word space or other separator) of the existing DC:Description metadata.
The following code will prefix/prepend the filename without extension before the DC:Description (Photoshop Caption) metadata, separated by a word space:
#target bridge
// https://forums.adobe.com/message/10537060#10537060
prefixNametoDescMeta = {};
prefixNametoDescMeta.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/";
var Name = decodeURI(sels.name).replace(/\.[^\.]+$/, '');
md.Caption = Name + " " + md.Caption;
}
}
if (BridgeTalk.appName == "bridge"){
var menu = MenuElement.create( "command", "Prefix Filename to Description Metadata", "at the end of Tools");
menu.onSelect = prefixNametoDescMeta.execute;
}
Copy link to clipboard
Copied
I noticed it as well, there was md.Caption before Name, quite the contrary to that he stated in his title, but I wasn't sure wasn't it his intetnion to insert file name in front of existing description or like 'prepend' stands for put it at end.
Copy link to clipboard
Copied
Thank you so much !!!
Copy link to clipboard
Copied
If you wanted to add Name at beginning of Description why you were adding it at end?
Copy link to clipboard
Copied
I was just trying to get ANYTHING to work so I wanted to alter the minimum amount of script as possible.
Thanks for your help.
Copy link to clipboard
Copied
If anything that works then like I said your original code worked, didn't it?