Skip to main content
Known Participant
Oct 1, 2012 9:18 PM UTC
Answered

Script to move description metadata information into title field

I have tried for 2 days (off and on) to try to get Bridge CS6 to copy the information from the Description field to the Title field in the metadata. I can get it into the menu, but nothing happens when I modify other scripts. Any suggestions would be greatly appreciated.

If you want a good laugh, I can post my previous attempts.

This topic is closed to new replies. Start a new post to keep the conversation going.
Paul Riggott
Paul RiggottCorrect answer
Inspiring
Oct 1, 2012 9:59 PM UTC

This is one way to copy the information ...

#target bridge  
if( BridgeTalk.appName == "bridge" ) { 
descToTitle = MenuElement.create("command", "Description to Title", "at the end of Tools");
}
descToTitle.onSelect = function () {
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var thumb = app.document.selections;
    for(var s in thumb){
if(thumb.hasMetadata){
        var selectedFile = thumb.spec;
  var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
  var myXmp = myXmpFile.getXMP();
         var Description =  getArrayItems(XMPConst.NS_DC, "description");
        myXmp.deleteProperty(XMPConst.NS_DC, "title");
        myXmp.appendArrayItem(XMPConst.NS_DC, "title", Description, 0, XMPConst.ALIAS_TO_ALT_TEXT);
        myXmp.setQualifier(XMPConst.NS_DC, "title[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");
    }
function getArrayItems(ns, prop){
var arrItem=[];
try{
var items = myXmp.countArrayItems(ns, prop);
for(var i = 1;i <= items;i++){
arrItem.push(myXmp.getArrayItem(ns, prop, i));
     }
return arrItem;
}catch(e){alert(e +" Line: "+ e.line);}
}
        if (myXmpFile.canPutXMP(myXmp)) {
        myXmpFile.putXMP(myXmp);
        myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
         } else {
  xmpFile.closeFile();
        }
    }
}
   

5 replies

belindat
Participating Frequently
May 9, 2019 7:15 PM UTC

Can you tell me what the process is to save this as a .jsx? I understand which folder it goes into, and I have the code copy/pasted into Script Editor, but that utility doesn't like the copied code and I'm unable to save.

Translate
Legend
Jul 19, 2019 1:18 PM UTC

Can you post more information? What operating system? Script Editor on the Mac is for AppleScript, not Adobe Extendscript.

Translate
Paul Riggott
Paul RiggottCorrect answer
Inspiring
Oct 1, 2012 9:59 PM UTC

This is one way to copy the information ...

#target bridge  
if( BridgeTalk.appName == "bridge" ) { 
descToTitle = MenuElement.create("command", "Description to Title", "at the end of Tools");
}
descToTitle.onSelect = function () {
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var thumb = app.document.selections;
    for(var s in thumb){
if(thumb.hasMetadata){
        var selectedFile = thumb.spec;
  var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
  var myXmp = myXmpFile.getXMP();
         var Description =  getArrayItems(XMPConst.NS_DC, "description");
        myXmp.deleteProperty(XMPConst.NS_DC, "title");
        myXmp.appendArrayItem(XMPConst.NS_DC, "title", Description, 0, XMPConst.ALIAS_TO_ALT_TEXT);
        myXmp.setQualifier(XMPConst.NS_DC, "title[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");
    }
function getArrayItems(ns, prop){
var arrItem=[];
try{
var items = myXmp.countArrayItems(ns, prop);
for(var i = 1;i <= items;i++){
arrItem.push(myXmp.getArrayItem(ns, prop, i));
     }
return arrItem;
}catch(e){alert(e +" Line: "+ e.line);}
}
        if (myXmpFile.canPutXMP(myXmp)) {
        myXmpFile.putXMP(myXmp);
        myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
         } else {
  xmpFile.closeFile();
        }
    }
}
   

Translate
pwfasprodAuthor
Known Participant
Oct 1, 2012 10:05 PM UTC

100% What I needed! It worked flawlessly- thank you very much. Now, it will be interesting to compare yours with what I did to see where, exactly, I went wrong.

Translate