Copy Rating from jpg to dng?

General Discussion of Scripting for Adobe Bridge

Moderators: Tom, Kukurykus

Jaybee

Copy Rating from jpg to dng?

Post by Jaybee »

Thanks Paul

That's perfect! Just what I needed. Donation on it's way!

Cheers!

Jaybee
Jaybee

Copy Rating from jpg to dng?

Post by Jaybee »

Hi Paul,

Oops, spoke too soon lol

Runs 100% from ESTK with Bridge open. However, when I save from the ESTK as a .jsx and place it in the Bridge Startup Scripts folder and restart Bridge CS4 it Errors with:

Error in (path to script) - Line3: app.document.deselectAll(); undefined is not an object.

Says it may not be compatible with my version of Bridge, but of course it runs from the ESTK just fine.

Sorry...!

Jaybee
Paul MR

Copy Rating from jpg to dng?

Post by Paul MR »

Please try this, this will add a command at the bottom of Tools menu....

Code: Select all#target bridge   
if( BridgeTalk.appName == "bridge" ) { 

var jpgToPsd = new MenuElement( "command", "Copy Meta to PSD", "at the end of Tools" , "cpy2psd" );
}
jpgToPsd.onSelect = function () {
app.document.deselectAll();
var thumbs = app.document.getSelection("jpg");
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
for (var a in thumbs){
var Name = thumbs[a].spec.name.replace(/\.[^\.]+$/, '');
    var Rating='';
     var t = new Thumbnail(thumbs[a]);
     var md = t.synchronousMetadata;
      md.namespace = "http://purl.org/dc/elements/1.1/";
      var Desc = "'"+ md.description+"'";
      if(Desc != "''") Desc = Desc.replace(/'/g,'');
      md.namespace = "http://ns.adobe.com/photoshop/1.0/";
      var Keys = md.Keywords;
      var PSD = File(thumbs[a].spec.path + "/"+Name + ".psd");
      if(PSD.exists){
try{
var thumb = new Thumbnail(PSD);
var selectedFile = thumb.spec;   
var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
var myXmp = myXmpFile.getXMP();
if(Desc != '""'){
myXmp.deleteProperty(XMPConst.NS_DC, "description");
myXmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", Desc );
}
if(Keys.length >0){
myXmp.deleteProperty(XMPConst.NS_DC,'subject');
for(var s in Keys){
myXmp.appendArrayItem(XMPConst.NS_DC, "subject", Keys[s], 0,XMPConst.PROP_IS_ARRAY);
    }
}
if (myXmpFile.canPutXMP(myXmp)) {
        myXmpFile.putXMP(myXmp);
         myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
         }
     }catch(e){alert(e+ " occured at line : " + e.line);}
          }
}
}
Jaybee

Copy Rating from jpg to dng?

Post by Jaybee »

Hi Paul,

That's the one! Bridge CS4 is now starting and behaving normally and I'm seeing 'Copy meta to PSD' at the bottom of the Tools menu. One click and it all works fine

A thousand thanks for your time and patience sir, this is going to be extremely useful. I'm continually amazed at what can be accomplished with scripting.

Cheers!

Jaybee