• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Watched folder functionality

LEGEND ,
Jul 26, 2019 Jul 26, 2019

Copy link to clipboard

Copied

I shoot product photos tethered with Canon Utility and review the captures in Bridge. Canon Utility has a linked software setting which calls an app after each capture. On the Mac, this feature switches focus to Bridge but on Windows 10, Canon Utility won't switch to Bridge automatically. I don't know if this is an Adobe or Canon bug.

Bridge unfortunately doesn't have a watched folder (sometimes called a hot folder) feature, so there is no built-in way to fix the problem.

I decided to write a watched folder script that can run arbitrary functions. This works perfectly and fixes the problem I'm having. It can be easily modified to do pretty much any processing that was needed and can be scripted.

Add the script below to Startup Scripts and run it to start the operation.

This could be modified to only work on a specific folder. When the menu item was selected, an choose folder dialog could allow hot folder selection and then the script could test to see if that was the active folder before processing.

---------------------------------------------

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

    try{

        var wfMenu = MenuElement.create('command', 'Watched Folder', 'at the end of Tools'); //create new menu command

       

        wfMenu.onSelect = function(){

            //choose folder dialog could be added here to set a specific hot folder

            app.eventHandlers.push({handler: wfOpenDocument}); //runs on window load

       

            function wfOpenDocument(event){

                if(event.object instanceof Document && event.type == 'loaded'){

                    //if a hot folder was defined, would test for it here

                    app.bringToFront(); //do stuff here

                    }

                }

            }

        }

    catch(e){

        alert(e + e.line);

        }

    }

TOPICS
Scripting

Views

525

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 26, 2019 Jul 26, 2019

Copy link to clipboard

Copied

I should add, this only works if the watched folder is open in a Bridge browser window. The idea is that changes to that folder will invoke the event, even when Bridge is in the background.

On the Mac, its easy to define a watched folder with AppleScript or Automator and call Bridge. Windows doesn't have the same functionality.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 08, 2019 Oct 08, 2019

Copy link to clipboard

Copied

Thanks for sharing your script! It's useful and an illustrative example of making a watched folder.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 24, 2019 Oct 24, 2019

Copy link to clipboard

Copied

LATEST

And probably a better way... rather than rely on the Loaded event, this script registers a callback if a property changes. This way, the watched folder doesn't have to be displayed. This could be paired with a script to unregister (unwatch) folders as desired.

--------------------------------------


#target bridge
if(BridgeTalk.appName == 'bridge'){
   try{
      var wfMenu = MenuElement.create('command', 'Watched Folder', 'at the end of Tools'); //create new menu command
      wfMenu.onSelect = function(){
         try{
            var sFolder = app.document.thumbnail; //current displayed folder
            if(! sFolder.container){ //make sure its a folder
               var wFolder = Folder.selectDialog('Select Watched Folder'); //dialog
               }
            else{
               var wFolder = Folder(sFolder.spec.fsName).selectDlg('Select Watched Folder'); //dialog start at currently displayed folder
               }
            if(wFolder == null){ //user cancel
               return;
               }
            }

         catch(e){
            alert(e + e.line + ' Unable to choose Watched Folder');

            return;
            }
         var tFolder = new Thumbnail(wFolder); //make thumbnail from folder
         var tChildren = tFolder.children; //get children array
         tFolder.registerInterest(interestCallback); //register interest
         function interestCallback (tFolder, tChildren){ //called when folder contents changes
         app.document.bringToFront(); //do stuff here
         }
      }
   }
   catch(e){
      alert(e + e.line);
      }
   }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines