Skip to main content
stephend54917218
Participant
August 2, 2018
Answered

Adobe Bridge 2018 script to "Prepend filename to the Description"

  • August 2, 2018
  • 1 reply
  • 1343 views

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 ????

This topic has been closed for replies.
Correct answer Stephen Marsh

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.


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;

}

1 reply

Kukurykus
Legend
August 2, 2018

Your code works. Description you used is incorrect. Caption included in original code is that keyword you are looking for

Stephen Marsh
Community Expert
Community Expert
August 2, 2018

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.

Kukurykus
Legend
August 2, 2018

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.