Skip to main content
Participant
October 28, 2024
Question

Script for adding file name to Headline field in metadata

I've found scripts for adding file name to Title and file name to Decription fields but I need one to add file name to Headline field. I've tried modifying those other scripts to work for the Headline but I can't get it to work. Seems like the Headline field is blocked from having data added to it.

This topic is closed to new replies. Start a new post to keep the conversation going.

3 replies

Stephen Marsh
Community Expert
Community Expert
October 28, 2024
quote

I've found scripts for adding file name to Title and file name to Decription fields but I need one to add file name to Headline field. I've tried modifying those other scripts to work for the Headline but I can't get it to work. Seems like the Headline field is blocked from having data added to it.


By @Josh32154076x9ig

 

You need to target the appropriate namespace for the different metadata entries...

 

Headline = http://ns.adobe.com/photoshop/1.0/ 

 

Title = http://purl.org/dc/elements/1.1/ 

 

It also depends on whether one is writing to the legacy IPTC or current XMP metadata.

 

In short, it's a minefield!

 

 

Translate
Participant
October 28, 2024

Hi Stephen, Thank you so much for the quick and accurate reply. I just tried the script and it works great!

I also appreciate you showing how it functions, there's a lot going on in the metadata mine fields.

Thanks again!

Translate
Stephen Marsh
Community Expert
Community Expert
October 28, 2024

@Josh32154076x9ig 

 

 

// https://forums.adobe.com/thread/656144  
// https://forums.adobe.com/message/9744916  
// https://forums.adobe.com/message/9745231  
#target bridge  
addNametoMeta = {};  
addNametoMeta.execute = function(){  
  var sels = app.document.selections;  
  for (var i = 0; i < sels.length; i++){  
var md = sels[i].synchronousMetadata;  
    md.namespace = "http://ns.adobe.com/photoshop/1.0/";  
    var Name = decodeURI(sels[i].name).replace(/\.[^\.]+$/g, ' '); //remove extension   
    md.Headline = md.Headline + Name;  
  }  
}  
if (BridgeTalk.appName == "bridge"){  
var menu = MenuElement.create( "command", "Filename to XMP and IPTC Headline", "at the end of Tools");  
  menu.onSelect = addNametoMeta.execute;  
} 

 

Or:

 

#target bridge

addTitleToHeadline = {};

addTitleToHeadline.execute = function () {
    var sels = app.document.selections;
    for (var i = 0; i < sels.length; i++) {
        var md = sels[i].synchronousMetadata;
        md.namespace = "http://ns.adobe.com/photoshop/1.0/";
        var Name = decodeURI(sels[i].name).replace(/\.[^\.]+$/g, ' '); //remove extension
        md.Headline = Name;
    }
}

if (BridgeTalk.appName == "bridge") {
    var menu = MenuElement.create("command", "Add Filename to Headline", "at the end of Tools");
    menu.onSelect = addTitleToHeadline.execute;
}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

Translate