Skip to main content
Known Participant
November 11, 2014
Question

Is it possible to modify this script to include subfolders?

  • November 11, 2014
  • 1 reply
  • 904 views

I have tried to do this with no luck. This script works great, but how to I make it apply to all sub-folders? Thanks for any suggestions.

#target bridge  

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

descToTitle = MenuElement.create("command", "Keys 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, "keywords");

        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();

        }

    }

}

This topic has been closed for replies.

1 reply

Inspiring
November 11, 2014

There is no need to modify the script as it works on selected files, all you need to do is have "show Items from Subfolders" ticked in the view menu and select the files you want the script to modify.

pwfasprodAuthor
Known Participant
November 11, 2014

I have done that, but for some reason that feature is not working in my copy of Bridge.

Not to mention, I need to do this on thousands of images. That is why the subfolder feature would be helpful.

However, I also thought about creating a collection with all of the images in it.

Inspiring
August 20, 2015

Any luck? I have around 5000 folders, with about 200 images in each so showing items from subfolders tends to crash Bridge