Skip to main content
Legend
February 21, 2023
Answered

Running EXIFTool from Bridge with app.system()

  • February 21, 2023
  • 7 replies
  • 4068 views

:EDIT: Got it working, the entire executable path is required.

 

 

Since I discovered that Bridge can't perform a bunch of operations on XMP/EXIF data, I have been working on hooking up EXIFTool to Bridge. I have been going round and round and CANNOT get EXIFTool to run using app.system().

 

I do use this function in other scripts, and I'm able to call other executables (I've used it with Adobe DNG Converter, cURL, and have been able to run simple things like dir/ls and redirect the output to a file.

 

If I call the command, it just silently fails. Bridge doesn't have a way for commands to send an error message back so I'm just in the dark. Writing the command to an alert window, copying it, then running THAT in a command window works on both platforms.

 

This is a very simple command that fails (on the Mac, its installed in the command path so just calling "exiftool" works in Terminal.)

 

    var cmd = "C:/Users/converse/Downloads/exiftool.exe -a -ALL -G1 -s C:/Users/converse/Desktop/04068.jpg > C:/Users/converse/Desktop/log.txt";
    app.system(cmd);

 

Adding single or double quote marks to the filename is no help. Copying that and running it on the command line works on both platforms. Replacing the exiftool call with "dir" or "ls -la" will write correctly to the log file. Same result with processing files, can't call a working command with app.system().

 

I'm wondering if anyone has gotten this working and how? It seems like it SHOULD work ok.

This topic has been closed for replies.
Correct answer Lumigraphics

And new versions- fixed a couple of bugs that Greg pointed out, no longer looping exiftool when processing multiple files, other minor improvements.

 

/*
Utility Pack Scripts created by David M. Converse ©2018-23

This script displays an EXIFTool info panel in the Bridge browser.

Last modified 3/28/23

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#target bridge
if(BridgeTalk.appName == 'bridge'){
    try{
        var EXIFInfo = new Object; //id object for this script
        EXIFInfo.built = false;
        var menuexifInfo = MenuElement.create('command', 'EXIFtool Info', 'at the end of Tools'); //create new menu command
        }
    catch(e){
        alert(e + ' ' + e.line);
        }
    }

    app.eventHandlers.push({handler: exifOpenDocument}); //runs on change in selections

    menuexifInfo.onSelect = function(){
        exifInfo();
        }

    function exifInfo(){
        try{
            this.paletteRefs = new Array();
            var exifWrapper = this;
            addexifInfoPalette(app.documents[0]);

            function addexifInfoPalette(doc){ //create tabbed palette
                if(Folder.fs == "Windows"){
                    var loc = "exiftool"; //exiftool.exe MUST be in Windows $PATH
                    }
                else{
                    var loc = "/usr/local/bin/exiftool"; //Mac location
                    if(!File(loc).exists){ //exiftool MUST be installed in default location
                        Window.alert("EXIFTool must be installed to use this script. Please visit exiftool.org/install.html for more info.");
                        return;
                        }
                    }
                if(EXIFInfo.built == false){ //first run
                    if(BridgeTalk.appVersion < 13){
                        var exifScriptPalette = new TabbedPalette(doc, 'EXIF Info', 'exifPre', 'script', 'center', 'top'); //place in center temporarily
                        exifScriptPalette.setLocation('right', 'top'); //move to final position, works around Bridge bug
                        }
                    else{
                        var exifScriptPalette = new TabbedPalette(doc, 'EXIF Info', 'exifPre', 'script');
                        }
                    var flags = " -a -ALL -G -s2 "; //flags
                    exifWrapper.paletteRefs.push(exifScriptPalette);
                    exifScriptPalette.content.orientation = 'column';
                    exifGroup = exifScriptPalette.content.add('group', undefined, '');
                    exifGroup.alignment = ['fill', 'top'];
                    exifGroup.alignChildren = ['fill', 'fill'];
                    exifGroup.orientation = 'row';
                    exifGroup.margins = [15, 15, 0, 0];
                    exifGroup.button = exifGroup.add('button', undefined, 'EXIFTool');
                    exifGroup.button.maximumSize = [75, 15];
                    exifGroup.checkbox = exifGroup.add('checkbox', undefined, 'Edit flags');
                    exifGroup.checkbox.value = false;
                    exifGroup.flagstxt = exifGroup.add('edittext {justify:"left"}');
                    exifGroup.flagstxt.text = flags;
                    exifGroup.flagstxt.visible = false;
                    exifGroup.flagstxt.minimumSize = [120, 15];
                    exifGroup2 = exifScriptPalette.content.add('group', undefined, '');
                    exifGroup2.alignment = ['fill', 'fill'];
                    exifGroup2.alignChildren = ['fill', 'fill'];
                    exifGroup2.orientation = 'column';
                    exifGroup2.txtField = exifGroup2.add('edittext', undefined, '', {multiline:true, readonly:true});
                    exifScriptPalette.content.layout.layout(true);
                    var exifc = exifScriptPalette.content.bounds
                    exifGroup2.bounds = [exifc[0] - 2, exifc[1] - 2, exifc[2] - 2, exifc[3] - 4];
                    var exifb = exifGroup2.bounds;
                    exifGroup2.txtField.bounds = [exifb[0] - 10, exifb[1] - 10, exifb[2] - 45, exifb[3] - 40];
                    exifScriptPalette.content.layout.layout(true);
                    EXIFInfo.built = true;

                    exifScriptPalette.content.onResize = function(){ //dynamic resizing
                        exifGroup2.bounds = exifb;
                        exifGroup2.txtField.bounds = [exifb[0] - 10, exifb[1] - 10, exifb[2] - 45, exifb[3] - 35];
                        this.layout.resize(true);
                        exifScriptPalette.content.layout.layout(true);
                        }

                    exifGroup.checkbox.onClick = function(){
                        if(exifGroup.checkbox.value == true){
                            exifGroup.flagstxt.visible = true;
                            }
                        else{
                            exifGroup.flagstxt.visible = false;
                            }
                        }

                    exifGroup.button.onClick = function(){
                        try{
                            var sel = app.document.selections; //Bridge selections
                            if(sel.length == 0){
                                return;
                                }
                            var cmd = loc; //base command
                            flags = exifGroup.flagstxt.text;
                            var tempFile = new File(Folder.temp + '/exiftemp.txt');
                            var imgPath = ""; //initialize image path
                            var img = ""; //initialize quote path
                            imgPath = sel[0].spec.fsName; //image path
                            img = " \"" + imgPath + "\""; //quote path
                            //composite command
                            cmd = cmd + flags + img + ' > ' + tempFile.fsName;
                            app.system(cmd);
                            tempFile.open ('r')
                            var exifresult = tempFile.read();
                            exifGroup2.txtField.text = exifresult;
                            tempFile.close();
                            tempFile.remove();
                            }
                        catch(e){
                            Window.alert(e + e.line);
                            }
                        }

                    exifScriptPalette.onClose = function(){
                        EXIFInfo.built = false;
                        }
                    }
                }
            }
        catch(e){
            alert(e + ' ' + e.line);
        }
    }

     function exifOpenDocument(event){ //new selection
        if(event.object instanceof Document && event.type == 'selectionsChanged' && EXIFInfo.built == true){
            try{
                exifGroup2.txtField.text = '';
                }
            catch(e){
                alert(e + ' ' + e.line);
                }
            return{handled:false};
            }
        }

 

/*
Utility Pack Scripts created by David M. Converse ©2018-23

This script strips EXIF/XMP camera data using EXIFTool

Last modifed 2/28/2023

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#target bridge
    if(BridgeTalk.appName == 'bridge'){
        //create menu
        var exifStrip = MenuElement.create('command', 'Strip EXIF', 'after Thumbnail/Open', this.menuID); //add to Contextual menu
        if(ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript'); //load library for metadata
        exifStrip.onSelect = function(){
            if(Folder.fs == "Windows"){
                var loc = "exiftool"; //exiftool.exe MUST be in Windows $PATH
                }
            else{
                var loc = "/usr/local/bin/exiftool"; //Mac location
                if(!File(loc).exists){ //exiftool MUST be installed in default location
                    Window.alert("EXIFTool must be installed to use this script. Please visit exiftool.org/install.html for more info.");
                    return;
                    }
                }
            exifMain(loc);
            }

        exifMain = function(loc){
            var flags = " -XMP-exifEX:All= -XMP-aux:All= -EXIFIFD:LensInfo= -EXIFIFD:SerialNumber= -EXIFIFD:LensModel= -XMP-xmpMM:All= -EXIF:All= -tagsfromfile @ -EXIF:ImageWidth -EXIF:ImageHeight -EXIF:XResolution -EXIF:YResolution -overwrite_original ";
            var Thumbs = app.document.selections; //apply to all selected thumbs
            var cmd = loc + flags;
            try{
                for(var a = 0; a < Thumbs.length; a++){
                    if(Thumbs[a].hasMetadata){
                        cmd = cmd + '\"' + Thumbs[a].spec.fsName + '\" ';
                        }
                    }
                app.system(cmd);
                }
            catch(e){
                alert(e + ' ' + e.line);
                }
            }
        }

 

7 replies

Legend
March 7, 2023

And one more quick update, please download the "Run EXIFTool" script from Dropbox to replace the "Strip EXIF" script. Thanks 🙂

https://www.dropbox.com/sh/mg817g9a9ymbasi/AADTmXUVxmFfM58bcyYE7yiwa?dl=0

gregreser
Legend
March 7, 2023

It's working great on Wondows 10 Bridge 2023. I like the addition of Auto-refresh.

 

Stephen Marsh
Community Expert
Community Expert
March 7, 2023

@Lumigraphics – OK, here are my initial findings from playing with the EXIFInfo.jsx script:

 

Version Support Comments:

 

* 2019 Mac – Loads without error, but no results from GUI, so no good! I understand that this is an old version and that you may only be programming for 2023 as the main version as Adobe has made so many changes to how Bridge 2023 supports scripts compared to old versions.

 

* 2021 Mac – Loads without error, the panel has to be manually made visible (Window > EXIF Info Panel), it works from the GUI, so all good!

 

* 2022 Mac – Loads without error, the panel has to be manually made visible (Window > EXIF Info Panel), it works from the GUI, so all good!

 

* 2023 Mac – Loads without error, and the panel is automatically made visible (but it is not visible under Window > EXIF Info Panel as with older versions) – it works from the GUI, so all good!

 

Windows – Untested.

 

Flag Options:

 

The default arguments in your script are:

 

-a -ALL -G -s2
 
I mostly use:
 

-a -G1 -s -u

 

These are basically the same, I'll need to refresh my memory on the pros/cons of Group tags vs Group1 or Group2 tags etc.

 

I also use the -u or -unknown flag in order to extract the most info that I can.

 
Miscellaneous Hack: 

 

I found that it is also possible to hack this into a GUI front end by showing the flags and putting in totally different arguments... but it is a little fussy as it isn't intended for that purpose and one then has to put back in the original flags afterwards, or at least just -All for a quick reset.

 

I think that it is useful to have a version that can just be used as a GUI to select files/folders and offer a blank "command line" to manually enter user commands as required (obviously only for more advanced users).

 

Legend
March 7, 2023

I have only tested on 2022 and 2023 Mac and 2022 Windows at this point. I have a Windows machine with older versions and a Mac at work, and both at home. It should load and show just fine on the Mac, not hidden. Not having issues here.

And yes I want to come up with a better way to edit flags, and I am a newb to exiftool so I just picked what looked like a good set.

Stephen Marsh
Community Expert
Community Expert
March 7, 2023

@Lumigraphics – Some feedback, first on the Strip EXIF.jsx script as it has less to comment on or discuss...

 

Version Support:

* 2019 Mac – Loads without error, right-click works and the command is successfully executed, all good!

* 2021 Mac – Loads without error, right-click works and the command is successfully executed, all good!

* 2022 Mac – Loads without error, right-click works and the command is successfully executed, all good!

* 2023 Mac – Loads without error, right-click works and the command is successfully executed, all good!

* Windows – Currently untested.

 

Right-Click Menu Name:

Although it is easy enough to edit the script myself, I personally prefer the right-click menu item name to identify that this is using ExifTool, just in case there is confusion with other scripts previously installed that may have been using standard Adobe scripting metadata edits rather than ExifTool. Not a big deal if you don't agree, I just think that it is more transparent putting ExifTool in the script menu name.

 

P.S. Thanks for mentioning in your PM the "advanced" CMD/CTRL Easter Egg feature, I haven't explored the code in detail yet and didn't notice it in there!

Legend
March 7, 2023

Ok cool! I'm not sure on names, something short and descriptive is best I guess.

I still have a bunch of work to do on both platforms, but these versions are at least usable.

Stephen Marsh
Community Expert
Community Expert
March 7, 2023

Usable it is!

 

I'll come back to you soon on my initial tyre kicking of the "EXIFInfo.jsx" script.

Stephen Marsh
Community Expert
Community Expert
March 7, 2023

@Lumigraphics 

 

David, I know that you know this, however, you have created a thing of beauty here! Kudos to you.

 

I personally consider a GUI for ExifTool to be a crutch, however, I do completely understand how daunting and offputting a CLI is for the "average user".

 

Providing a link between Bridge and ExifTool is a huge thing, you have provided a great service to the image editing community with this project.

 

Thank you!

 

 

@gregreser – I'd also like to thank you too for your contributions here!

Legend
March 7, 2023

Thank you, most of the tools I've written have been for my production use or for me to learn. I know exiftool a lot better than I did a few weeks ago.  I'm glad if people can use them.

LumigraphicsAuthorCorrect answer
Legend
February 28, 2023

And new versions- fixed a couple of bugs that Greg pointed out, no longer looping exiftool when processing multiple files, other minor improvements.

 

/*
Utility Pack Scripts created by David M. Converse ©2018-23

This script displays an EXIFTool info panel in the Bridge browser.

Last modified 3/28/23

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#target bridge
if(BridgeTalk.appName == 'bridge'){
    try{
        var EXIFInfo = new Object; //id object for this script
        EXIFInfo.built = false;
        var menuexifInfo = MenuElement.create('command', 'EXIFtool Info', 'at the end of Tools'); //create new menu command
        }
    catch(e){
        alert(e + ' ' + e.line);
        }
    }

    app.eventHandlers.push({handler: exifOpenDocument}); //runs on change in selections

    menuexifInfo.onSelect = function(){
        exifInfo();
        }

    function exifInfo(){
        try{
            this.paletteRefs = new Array();
            var exifWrapper = this;
            addexifInfoPalette(app.documents[0]);

            function addexifInfoPalette(doc){ //create tabbed palette
                if(Folder.fs == "Windows"){
                    var loc = "exiftool"; //exiftool.exe MUST be in Windows $PATH
                    }
                else{
                    var loc = "/usr/local/bin/exiftool"; //Mac location
                    if(!File(loc).exists){ //exiftool MUST be installed in default location
                        Window.alert("EXIFTool must be installed to use this script. Please visit exiftool.org/install.html for more info.");
                        return;
                        }
                    }
                if(EXIFInfo.built == false){ //first run
                    if(BridgeTalk.appVersion < 13){
                        var exifScriptPalette = new TabbedPalette(doc, 'EXIF Info', 'exifPre', 'script', 'center', 'top'); //place in center temporarily
                        exifScriptPalette.setLocation('right', 'top'); //move to final position, works around Bridge bug
                        }
                    else{
                        var exifScriptPalette = new TabbedPalette(doc, 'EXIF Info', 'exifPre', 'script');
                        }
                    var flags = " -a -ALL -G -s2 "; //flags
                    exifWrapper.paletteRefs.push(exifScriptPalette);
                    exifScriptPalette.content.orientation = 'column';
                    exifGroup = exifScriptPalette.content.add('group', undefined, '');
                    exifGroup.alignment = ['fill', 'top'];
                    exifGroup.alignChildren = ['fill', 'fill'];
                    exifGroup.orientation = 'row';
                    exifGroup.margins = [15, 15, 0, 0];
                    exifGroup.button = exifGroup.add('button', undefined, 'EXIFTool');
                    exifGroup.button.maximumSize = [75, 15];
                    exifGroup.checkbox = exifGroup.add('checkbox', undefined, 'Edit flags');
                    exifGroup.checkbox.value = false;
                    exifGroup.flagstxt = exifGroup.add('edittext {justify:"left"}');
                    exifGroup.flagstxt.text = flags;
                    exifGroup.flagstxt.visible = false;
                    exifGroup.flagstxt.minimumSize = [120, 15];
                    exifGroup2 = exifScriptPalette.content.add('group', undefined, '');
                    exifGroup2.alignment = ['fill', 'fill'];
                    exifGroup2.alignChildren = ['fill', 'fill'];
                    exifGroup2.orientation = 'column';
                    exifGroup2.txtField = exifGroup2.add('edittext', undefined, '', {multiline:true, readonly:true});
                    exifScriptPalette.content.layout.layout(true);
                    var exifc = exifScriptPalette.content.bounds
                    exifGroup2.bounds = [exifc[0] - 2, exifc[1] - 2, exifc[2] - 2, exifc[3] - 4];
                    var exifb = exifGroup2.bounds;
                    exifGroup2.txtField.bounds = [exifb[0] - 10, exifb[1] - 10, exifb[2] - 45, exifb[3] - 40];
                    exifScriptPalette.content.layout.layout(true);
                    EXIFInfo.built = true;

                    exifScriptPalette.content.onResize = function(){ //dynamic resizing
                        exifGroup2.bounds = exifb;
                        exifGroup2.txtField.bounds = [exifb[0] - 10, exifb[1] - 10, exifb[2] - 45, exifb[3] - 35];
                        this.layout.resize(true);
                        exifScriptPalette.content.layout.layout(true);
                        }

                    exifGroup.checkbox.onClick = function(){
                        if(exifGroup.checkbox.value == true){
                            exifGroup.flagstxt.visible = true;
                            }
                        else{
                            exifGroup.flagstxt.visible = false;
                            }
                        }

                    exifGroup.button.onClick = function(){
                        try{
                            var sel = app.document.selections; //Bridge selections
                            if(sel.length == 0){
                                return;
                                }
                            var cmd = loc; //base command
                            flags = exifGroup.flagstxt.text;
                            var tempFile = new File(Folder.temp + '/exiftemp.txt');
                            var imgPath = ""; //initialize image path
                            var img = ""; //initialize quote path
                            imgPath = sel[0].spec.fsName; //image path
                            img = " \"" + imgPath + "\""; //quote path
                            //composite command
                            cmd = cmd + flags + img + ' > ' + tempFile.fsName;
                            app.system(cmd);
                            tempFile.open ('r')
                            var exifresult = tempFile.read();
                            exifGroup2.txtField.text = exifresult;
                            tempFile.close();
                            tempFile.remove();
                            }
                        catch(e){
                            Window.alert(e + e.line);
                            }
                        }

                    exifScriptPalette.onClose = function(){
                        EXIFInfo.built = false;
                        }
                    }
                }
            }
        catch(e){
            alert(e + ' ' + e.line);
        }
    }

     function exifOpenDocument(event){ //new selection
        if(event.object instanceof Document && event.type == 'selectionsChanged' && EXIFInfo.built == true){
            try{
                exifGroup2.txtField.text = '';
                }
            catch(e){
                alert(e + ' ' + e.line);
                }
            return{handled:false};
            }
        }

 

/*
Utility Pack Scripts created by David M. Converse ©2018-23

This script strips EXIF/XMP camera data using EXIFTool

Last modifed 2/28/2023

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#target bridge
    if(BridgeTalk.appName == 'bridge'){
        //create menu
        var exifStrip = MenuElement.create('command', 'Strip EXIF', 'after Thumbnail/Open', this.menuID); //add to Contextual menu
        if(ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript'); //load library for metadata
        exifStrip.onSelect = function(){
            if(Folder.fs == "Windows"){
                var loc = "exiftool"; //exiftool.exe MUST be in Windows $PATH
                }
            else{
                var loc = "/usr/local/bin/exiftool"; //Mac location
                if(!File(loc).exists){ //exiftool MUST be installed in default location
                    Window.alert("EXIFTool must be installed to use this script. Please visit exiftool.org/install.html for more info.");
                    return;
                    }
                }
            exifMain(loc);
            }

        exifMain = function(loc){
            var flags = " -XMP-exifEX:All= -XMP-aux:All= -EXIFIFD:LensInfo= -EXIFIFD:SerialNumber= -EXIFIFD:LensModel= -XMP-xmpMM:All= -EXIF:All= -tagsfromfile @ -EXIF:ImageWidth -EXIF:ImageHeight -EXIF:XResolution -EXIF:YResolution -overwrite_original ";
            var Thumbs = app.document.selections; //apply to all selected thumbs
            var cmd = loc + flags;
            try{
                for(var a = 0; a < Thumbs.length; a++){
                    if(Thumbs[a].hasMetadata){
                        cmd = cmd + '\"' + Thumbs[a].spec.fsName + '\" ';
                        }
                    }
                app.system(cmd);
                }
            catch(e){
                alert(e + ' ' + e.line);
                }
            }
        }

 

Legend
February 27, 2023

Test versions:

/*
Utility Pack Scripts created by David M. Converse ©2018-23

This script displays an EXIFTool info panel in the Bridge browser.

Last modified 3/27/23

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#target bridge
if(BridgeTalk.appName == 'bridge'){
    try{
        var EXIFInfo = new Object; //id object for this script
        EXIFInfo.built = false;
        var menuexifInfo = MenuElement.create('command', 'EXIFtool Info', 'at the end of Tools'); //create new menu command
        }
    catch(e){
        alert(e + ' ' + e.line);
        }
    }

    app.eventHandlers.push({handler: exifOpenDocument}); //runs on change in selections

    menuexifInfo.onSelect = function(){
        exifInfo();
        }

    function exifInfo(){
        try{
            this.paletteRefs = new Array();
            var exifWrapper = this;
            addexifInfoPalette(app.documents[0]);

            function addexifInfoPalette(doc){ //create tabbed palette
                if(Folder.fs == "Windows"){
                    var loc = "exiftool"; //exiftool.exe MUST be in Windows $PATH
                    }
                else{
                    var loc = "/usr/local/bin/exiftool"; //Mac location
                    if(!File(loc).exists){ //exiftool MUST be installed in default location
                        Window.alert("EXIFTool must be installed to use this script. Please visit exiftool.org/install.html for more info.");
                        return;
                        }
                    }
                if(EXIFInfo.built == false){ //first run
                    if(vers[0] < 13){
                        var exifScriptPalette = new TabbedPalette(doc, 'EXIF Info', 'exifPre', 'script', 'center', 'top'); //place in center temporarily
                        exifScriptPalette.setLocation('right', 'top'); //move to final position, works around Bridge bug
                        }
                    else{
                        var exifScriptPalette = new TabbedPalette(doc, 'EXIF Info', 'exifPre', 'script');
                        }
                    var flags = " -a -ALL -G -s2 "; //flags
                    exifWrapper.paletteRefs.push(exifScriptPalette);
                    exifScriptPalette.content.orientation = 'column';
                    exifGroup = exifScriptPalette.content.add('group', undefined, '');
                    exifGroup.alignment = ['fill', 'top'];
                    exifGroup.alignChildren = ['fill', 'fill'];
                    exifGroup.orientation = 'row';
                    exifGroup.margins = [15, 15, 0, 0];
                    exifGroup.button = exifGroup.add('button', undefined, 'EXIFTool');
                    exifGroup.button.maximumSize = [50, 15];
                    exifGroup.checkbox = exifGroup.add('checkbox', undefined, 'Edit flags');
                    exifGroup.checkbox.value = false;
                    exifGroup.flagstxt = exifGroup.add('edittext {justify:"left"}');
                    exifGroup.flagstxt.text = flags;
                    exifGroup.flagstxt.visible = false;
                    exifGroup.flagstxt.minimumSize = [120, 15];
                    exifGroup2 = exifScriptPalette.content.add('group', undefined, '');
                    exifGroup2.alignment = ['fill', 'fill'];
                    exifGroup2.alignChildren = ['fill', 'fill'];
                    exifGroup2.orientation = 'column';
                    exifGroup2.txtField = exifGroup2.add('edittext', undefined, '', {multiline:true, readonly:true});
                    exifScriptPalette.content.layout.layout(true);
                    var exifc = exifScriptPalette.content.bounds
                    exifGroup2.bounds = [exifc[0] - 2, exifc[1] - 2, exifc[2] - 2, exifc[3] - 4];
                    var exifb = exifGroup2.bounds;
                    exifGroup2.txtField.bounds = [exifb[0] - 10, exifb[1] - 10, exifb[2] - 45, exifb[3] - 40];
                    exifScriptPalette.content.layout.layout(true);
                    EXIFInfo.built = true;

                    exifScriptPalette.content.onResize = function(){ //dynamic resizing
                        exifGroup2.bounds = exifb;
                        exifGroup2.txtField.bounds = [exifb[0] - 10, exifb[1] - 10, exifb[2] - 45, exifb[3] - 35];
                        this.layout.resize(true);
                        exifScriptPalette.content.layout.layout(true);
                        }

                    exifGroup.checkbox.onClick = function(){
                        if(exifGroup.checkbox.value == true){
                            exifGroup.flagstxt.visible = true;
                            }
                        else{
                            exifGroup.flagstxt.visible = false;
                            }
                        }

                    exifGroup.button.onClick = function(){
                        try{
                            var sel = app.document.selections; //Bridge selections
                            if(sel.length == 0){
                                return;
                                }
                            var cmd = loc; //base command
                            flags = exifGroup.flagstxt.text;
                            var tempFile = new File(Folder.temp + '/exiftemp.txt');
                            var imgPath = ""; //initialize image path
                            var img = ""; //initialize quote path
                            imgPath = sel[0].spec.fsName; //image path
                            img = " \"" + imgPath + "\""; //quote path
                            //composite command
                            cmd = cmd + flags + img + ' > ' + tempFile.fsName;
                            app.system(cmd);
                            tempFile.open ('r')
                            var exifresult = tempFile.read();
                            exifGroup2.txtField.text = exifresult;
                            tempFile.close();
                            tempFile.remove();
                            }
                        catch(e){
                            Window.alert(e + e.line);
                            }
                        }

                    exifScriptPalette.onClose = function(){
                        EXIFInfo.built = false;
                        }
                    }
                }
            }
        catch(e){
            alert(e + ' ' + e.line);
        }
    }

     function exifOpenDocument(event){ //new selection
        if(event.object instanceof Document && event.type == 'selectionsChanged' && EXIFInfo.built == true){
            try{
                exifGroup2.txtField.text = '';
                }
            catch(e){
                alert(e + ' ' + e.line);
                }
            return{handled:false};
            }
        }

 

/*
Utility Pack Scripts created by David M. Converse ©2018-23

This script strips EXIF/XMP camera data using EXIFTool

Last modifed 2/27/2023

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#target bridge
    if(BridgeTalk.appName == 'bridge'){
        //create menu
        var exifStrip = MenuElement.create('command', 'Strip EXIF', 'after Thumbnail/Open', this.menuID); //add to Contextual menu

        exifStrip.onSelect = function(){
            if(Folder.fs == "Windows"){
                var loc = "exiftool"; //exiftool.exe MUST be in Windows $PATH
                }
            else{
                var loc = "/usr/local/bin/exiftool"; //Mac location
                if(!File(loc).exists){ //exiftool MUST be installed in default location
                    Window.alert("EXIFTool must be installed to use this script. Please visit exiftool.org/install.html for more info.");
                    return;
                    }
                }
            exifMain(loc);
            }

        exifMain = function(loc){
            var Thumbs = app.document.selections; //apply to all selected thumbs
            if(ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript'); //load library for metadata
            for(var a = 0; a < Thumbs.length; a++){
                try{
                    if(Thumbs[a].hasMetadata){
                        var cmd = loc + " -XMP-exifEX:All= -XMP-aux:All= -EXIFIFD:LensInfo= -EXIFIFD:SerialNumber= -EXIFIFD:LensModel= -XMP-xmpMM:All= -ext jpg -overwrite_original ";
                        cmd = cmd + '\"' + Thumbs[a].spec.fsName + '\"';
                        app.system(cmd);
                        }
                    }
                catch(e){
                    alert(e + ' ' + e.line);
                    }
                }
            }
        }
gregreser
Legend
February 27, 2023

@Lumigraphics EXIFInfo is very useful - nice solution.

Some small tweaks I made:

 

if(vers[0] < 13) is undefined (only a problem if Utility Script Pack is not installed). To run independently, I added:

var vers = BridgeTalk.appVersion;

 

Windows loc needs a forward slash before exiftool:

var loc = "/exiftool";

 

The EXIFTool button text was cutoff.

so I increased the width:

exifGroup.button.maximumSize = [75, 15];

 

Legend
February 28, 2023

Oh thanks! Yeah I pulled the include file but forgot to define the version. It's working for me with just "exiftool" no forward slash. I copied the executable into the \Windows folder which is probably some sort of sin. And yeah I saw the button. Bridge 13 won't launch on my Windows machine at work so testing has been a little hit or miss.

gregreser
Legend
February 23, 2023

I've been trying to get this to work too.  I tried simple commands using ffmpeg and got the same result - nothing. I wonder if app.system() has been locked down because of security concerns, or perhaps it's just broken.

Legend
February 23, 2023

I actually got it working on Windows, and even was able to direct error output to a text file. Of course you get the stupid command window stealing focus over and over since I haven't done the Powershell/Windows Script Host wrapper.

 

Still banging away on the Mac version.

gregreser
Legend
February 23, 2023

Nice! I'm curious to see your solution