Skip to main content
New Participant
April 13, 2016
Answered

Image Name to Metadata Title

  • April 13, 2016
  • 4 replies
  • 1545 views

Hello everyone,

Any one has a script for bridge or apple script to copy the image name (Image.psd) to a its Metadata Title caption author, etc.. without the extension (.psd)

Thank You

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

// https://imagesimple.wordpress.com/2011/08/24/cs5-filename-to-title-script/

#target bridge

  if( BridgeTalk.appName == "bridge" ) {

FT = MenuElement.create("command", "Add FileName to Title", "at the end of Tools");

}

FT.onSelect = function () {

  AddFilenameToTitle();

  }

function AddFilenameToTitle(){

var thumbs = app.document.selections;

if(!thumbs.length) return;

if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new

ExternalObject("lib:AdobeXMPScript");

for(var a in thumbs){

var selectedFile = thumbs.spec;

var Title = decodeURI(selectedFile.name).replace(/\.[^\.]+$/, '')

      var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN,

XMPConst.OPEN_FOR_UPDATE);

  var myXmp = myXmpFile.getXMP();

        myXmp.deleteProperty(XMPConst.NS_DC, "title");

        myXmp.appendArrayItem(XMPConst.NS_DC, "title", Title, 0,

XMPConst.ALIAS_TO_ALT_TEXT);

        myXmp.setQualifier(XMPConst.NS_DC, "title[1]",

"http://www.w3.org/XML/1998/namespace", "lang", "x-default");

        if (myXmpFile.canPutXMP(myXmp)) {

        myXmpFile.putXMP(myXmp);

        myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);

        }

    }

}

4 replies

ihajoAuthor
New Participant
April 13, 2016

The first code was the correct one the second one added a space before the name..

Thank you

Stephen Marsh
Adobe Expert
April 13, 2016

// Filename to metadata title.jsx

// https://forums.adobe.com/message/3596812

#target bridge

  if( BridgeTalk.appName == "bridge" ) {

FT = MenuElement.create("command", "Add FileName to Description", "at the end of Tools");

}

FT.onSelect = function () {

var thumbs = app.document.selections;

if(!thumbs.length) return;

if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

for(var a in thumbs){

var selectedFile = thumbs.spec;

var FileName = decodeURI(selectedFile.name).replace(/\.[^\.]+$/, '')

      var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);

  var myXmp = myXmpFile.getXMP();

var Desc=[];

var count =  myXmp.countArrayItems(XMPConst.NS_DC, "description");

for(var i = 1;i <= count;i++){

Desc.push(myXmp.getArrayItem(XMPConst.NS_DC, "description", i));

    }

Desc=Desc.toString() + " " + FileName;

        myXmp.deleteProperty(XMPConst.NS_DC, "description");

        myXmp.appendArrayItem(XMPConst.NS_DC, "description", Desc, 0, XMPConst.ALIAS_TO_ALT_TEXT);

        myXmp.setQualifier(XMPConst.NS_DC, "description[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");

        if (myXmpFile.canPutXMP(myXmp)) {

        myXmpFile.putXMP(myXmp);

        myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);

        }

    }

}

Stephen Marsh
Stephen MarshCorrect answer
Adobe Expert
April 13, 2016

// https://imagesimple.wordpress.com/2011/08/24/cs5-filename-to-title-script/

#target bridge

  if( BridgeTalk.appName == "bridge" ) {

FT = MenuElement.create("command", "Add FileName to Title", "at the end of Tools");

}

FT.onSelect = function () {

  AddFilenameToTitle();

  }

function AddFilenameToTitle(){

var thumbs = app.document.selections;

if(!thumbs.length) return;

if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new

ExternalObject("lib:AdobeXMPScript");

for(var a in thumbs){

var selectedFile = thumbs.spec;

var Title = decodeURI(selectedFile.name).replace(/\.[^\.]+$/, '')

      var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN,

XMPConst.OPEN_FOR_UPDATE);

  var myXmp = myXmpFile.getXMP();

        myXmp.deleteProperty(XMPConst.NS_DC, "title");

        myXmp.appendArrayItem(XMPConst.NS_DC, "title", Title, 0,

XMPConst.ALIAS_TO_ALT_TEXT);

        myXmp.setQualifier(XMPConst.NS_DC, "title[1]",

"http://www.w3.org/XML/1998/namespace", "lang", "x-default");

        if (myXmpFile.canPutXMP(myXmp)) {

        myXmpFile.putXMP(myXmp);

        myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);

        }

    }

}

SuperMerlin
Inspiring
April 13, 2016

There are various examples in this thread. copy filename to iptc description