I have modified that script, so hopefully it should now work for you. #target bridge if( BridgeTalk.appName == "bridge" ) { var newMenuData = new MenuElement( "menu", "Copy_Metadata", "after Help", "myMetaData" ); var newDataCommand = new MenuElement( "command", "Copy Metadata", "at the end of myMetaData" , "zxcv" ); } newDataCommand.onSelect = function () { renamePutXMP(); } function renamePutXMP(){ var win = new Window('dialog','Copy Metadata'); g = win.graphics; var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]); g.backgroundColor = myBrush; win.alignChildren="row"; win.g10 = win.add('group'); win.g10.orientation = "row"; win.title = win.g10.add('statictext',undefined,'Copy Metadata'); win.title.alignment="bottom"; var g = win.title.graphics; g.font = ScriptUI.newFont("Georgia","BOLDITALIC",22); win.p1= win.add("panel", undefined, undefined, {borderStyle:"black"}); win.p1.alignChildren="fill"; win.g5 =win.p1.add('group'); win.g5.spacing=10; win.g5.st1 = win.g5.add('statictext',undefined,'Source Files'); win.g5.st1.preferredSize=[100,20]; win.g5.et1 = win.g5.add('edittext'); win.g5.et1.preferredSize=[250,20]; win.g5.et1.enabled=false; win.g5.bu1 = win.g5.add('button',undefined,'Browse'); win.g10 =win.p1.add('group'); win.g10.spacing=10; win.g10.st1 = win.g10.add('statictext',undefined,'Destination Files'); win.g10.st1.preferredSize=[100,20]; win.g10.et1 = win.g10.add('edittext'); win.g10.et1.preferredSize=[250,20]; win.g10.et1.enabled=false; win.g10.bu1 = win.g10.add('button',undefined,'Browse'); win.g15 =win.p1.add('group'); win.g15.orientation='row'; win.g15.alignment="top"; win.g15.spacing=10; win.g15.bu1 = win.g15.add('button',undefined,'Process'); win.g15.bu1.preferredSize=[200,30]; win.g15.bu2 = win.g15.add('button',undefined,'Cancel'); win.g15.bu2.preferredSize=[200,30]; win.g5.bu1.onClick=function(){ rawFolder = Folder.selectDialog("Please select the Source folder",app.document.presentationPath); if(rawFolder !=null){ win.g5.et1.text = decodeURI(rawFolder.fsName); } } win.g10.bu1.onClick=function(){ destinationFolder = Folder.selectDialog("Please select the destination files folder",app.document.presentationPath); if(destinationFolder !=null){ win.g10.et1.text = decodeURI(destinationFolder.fsName); } } win.g15.bu1.onClick=function(){ if(win.g5.et1.text == ''){ alert("No Source folder selected!"); return; } if(win.g10.et1.text == ''){ alert("No Destination folder selected!"); return; } win.close(1); process(rawFolder,destinationFolder); } win.center(); win.show(); } function process(rawFolder,destinationFolder){ var rawFiles = rawFolder.getFiles (/\.(jpg)$/i); if(!rawFiles.length){alert("There are no source files to be processed!"); return;} for (var a in rawFiles){ var Name = decodeURI(rawFiles.name).replace(/\.[^\.]+$/, ''); var destFile = File(destinationFolder + "/" + Name + ".tif"); if(destFile.exists) updateMetaData(rawFiles,destFile); } } function updateMetaData(sourceFile,destFile){ if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript"); sourceFile = new Thumbnail(File(sourceFile)); destFile = new Thumbnail(File(destFile)); var md = sourceFile.synchronousMetadata; var source = new XMPMeta( md.serialize() ); var md2 = destFile.synchronousMetadata; var dest = new XMPMeta( md2.serialize() ); try{ copySchema( source, dest,XMPConst.NS_DC,[]); copySchema( source, dest,XMPConst.NS_XMP_RIGHTS,[]); copySchema( source, dest,XMPConst.NS_IPTC_CORE,[]); copySchema( source, dest,XMPConst.NS_PHOTOSHOP,[]); var updatedPacket = dest.serialize(XMPConst.SERIALIZE_OMIT_PACKET_WRAPPER | XMPConst.SERIALIZE_USE_COMPACT_FORMAT); destFile.metadata = new Metadata(updatedPacket); app.document.refresh(); }catch(e){alert(e+" "+e.line);} } function copySchema( source, dest, namespace, omitProps ) { var propIter = source.iterator(XMPConst.ITERATOR_JUST_CHILDREN | XMPConst.ITERATOR_JUST_LEAF_NAME, namespace, "" ); var prop = propIter.next(); var prefix = XMPMeta.getNamespacePrefix( namespace ); while(prop) { var name = prop.path.substring( prefix.length ); if(omitProps != undefined) var copy = !contains( omitProps, name); if( copy ) { try{ XMPUtils.duplicateSubtree( source, dest, namespace, prop.path,namespace, prop.path, 0 ); }catch(e){} } prop = propIter.next(); } } function contains( arr, member ){ var r = false; for( var i = 0; i < arr.length &! r; ++i ) { r = arr == member; } return r; } #target bridge if( BridgeTalk.appName == "bridge" ) { var newMenuData = new MenuElement( "menu", "Copy_Metadata", "after Help", "myMetaData" ); var newDataCommand = new MenuElement( "command", "Copy Metadata", "at the end of myMetaData" , "zxcv" ); } newDataCommand.onSelect = function () { renamePutXMP(); } function renamePutXMP(){ var win = new Window('dialog','Copy Metadata'); g = win.graphics; var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]); g.backgroundColor = myBrush; win.alignChildren="row"; win.g10 = win.add('group'); win.g10.orientation = "row"; win.title = win.g10.add('statictext',undefined,'Copy Metadata'); win.title.alignment="bottom"; var g = win.title.graphics; g.font = ScriptUI.newFont("Georgia","BOLDITALIC",22); win.p1= win.add("panel", undefined, undefined, {borderStyle:"black"}); win.p1.alignChildren="fill"; win.g5 =win.p1.add('group'); win.g5.spacing=10; win.g5.st1 = win.g5.add('statictext',undefined,'Source Files'); win.g5.st1.preferredSize=[100,20]; win.g5.et1 = win.g5.add('edittext'); win.g5.et1.preferredSize=[250,20]; win.g5.et1.enabled=false; win.g5.bu1 = win.g5.add('button',undefined,'Browse'); win.g10 =win.p1.add('group'); win.g10.spacing=10; win.g10.st1 = win.g10.add('statictext',undefined,'Destination Files'); win.g10.st1.preferredSize=[100,20]; win.g10.et1 = win.g10.add('edittext'); win.g10.et1.preferredSize=[250,20]; win.g10.et1.enabled=false; win.g10.bu1 = win.g10.add('button',undefined,'Browse'); win.g15 =win.p1.add('group'); win.g15.orientation='row'; win.g15.alignment="top"; win.g15.spacing=10; win.g15.bu1 = win.g15.add('button',undefined,'Process'); win.g15.bu1.preferredSize=[200,30]; win.g15.bu2 = win.g15.add('button',undefined,'Cancel'); win.g15.bu2.preferredSize=[200,30]; win.g5.bu1.onClick=function(){ rawFolder = Folder.selectDialog("Please select the Source folder",app.document.presentationPath); if(rawFolder !=null){ win.g5.et1.text = decodeURI(rawFolder.fsName); } } win.g10.bu1.onClick=function(){ destinationFolder = Folder.selectDialog("Please select the destination files folder",app.document.presentationPath); if(destinationFolder !=null){ win.g10.et1.text = decodeURI(destinationFolder.fsName); } } win.g15.bu1.onClick=function(){ if(win.g5.et1.text == ''){ alert("No Source folder selected!"); return; } if(win.g10.et1.text == ''){ alert("No Destination folder selected!"); return; } win.close(1); process(rawFolder,destinationFolder); } win.center(); win.show(); } function process(rawFolder,destinationFolder){ var rawFiles = rawFolder.getFiles (/\.(jpg)$/i); if(!rawFiles.length){alert("There are no source files to be processed!"); return;} for (var a in rawFiles){ var Name = decodeURI(rawFiles.name).replace(/\.[^\.]+$/, ''); var destFile = File(destinationFolder + "/" + Name + ".tif"); if(destFile.exists) updateMetaData(rawFiles,destFile); } } function updateMetaData(sourceFile,destFile){ if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript"); sourceFile = new Thumbnail(File(sourceFile)); destFile = new Thumbnail(File(destFile)); var md = sourceFile.synchronousMetadata; var source = new XMPMeta( md.serialize() ); var md2 = destFile.synchronousMetadata; var dest = new XMPMeta( md2.serialize() ); try{ copySchema( source, dest,XMPConst.NS_DC,[]); copySchema( source, dest,XMPConst.NS_XMP_RIGHTS,[]); copySchema( source, dest,XMPConst.NS_IPTC_CORE,[]); copySchema( source, dest,XMPConst.NS_PHOTOSHOP,[]); var updatedPacket = dest.serialize(XMPConst.SERIALIZE_OMIT_PACKET_WRAPPER | XMPConst.SERIALIZE_USE_COMPACT_FORMAT); destFile.metadata = new Metadata(updatedPacket); app.document.refresh(); }catch(e){alert(e+" "+e.line);} } function copySchema( source, dest, namespace, omitProps ) { var propIter = source.iterator(XMPConst.ITERATOR_JUST_CHILDREN | XMPConst.ITERATOR_JUST_LEAF_NAME, namespace, "" ); var prop = propIter.next(); var prefix = XMPMeta.getNamespacePrefix( namespace ); while(prop) { var name = prop.path.substring( prefix.length ); if(omitProps != undefined) var copy = !contains( omitProps, name); if( copy ) { try{ XMPUtils.duplicateSubtree( source, dest, namespace, prop.path,namespace, prop.path, 0 ); }catch(e){} } prop = propIter.next(); } } function contains( arr, member ){ var r = false; for( var i = 0; i < arr.length &! r; ++i ) { r = arr == member; } return r; }
... View more