Skip to main content
Participant
May 23, 2025
Question

do javascript error Bridge 2025, alternative ways?

  • May 23, 2025
  • 1 reply
  • 294 views

I'm new to javascript with Bridge.

I want to pass a filepath to Bridge 2025 using applescript and have Bridge reveal the file and also change the file's star ratings. The filepath is in Numbers and I pass it in a string variable to Bridge. If I use the open command, it works but there's a long delay of about 5 seconds before control is returned back to the ApppleScript -- too painful for many files to be run through quickly this way.

When I try to save the code below, I get an "Expected end of line" with javascript highlighted after "do".

 

In Bridge's startup script folder, I put the code shown below as recommended by AI.

This *prevents* the function "selectFile" from running until Applescript sends the request to run that function with the parameter "filepath" (according to AI). For ease of finding my script, I'd like to put this script in the StartupScript folder if I can keep it from running at startup, but putting it there isn't essential if it complicates things too much.

 

If "do applescript" will not work, is there something I can do to cut down the approx 5 sec delay when I use the Open command instead of "do javascript"? Bridge is open always ahead of the Open cmd being sent. I've cleared the cache for the cache to be rebuild. The file of interest always shows up nearly immediately -- even before I reset the cache, but I do see "indexing" show up sometimes during the 5 second delay before control returns to Applescript.

 

Since BridgeTalk seems to be for intra-Adobe communication, I'm not so sure that's appropriate to invoke here, but that's what AI provided and, in fact, the script doesn't attempt to run anymore when I first open Bridge to run.

 

Thanks in advance, for your help...

 

AppleScript

=========

set jsCode to "selectFile(\"" & thePath & "\");"

tell application "Adobe Bridge 2025"

activate

-- open thePath

  do javascript jsCode as string

beep

delay 0.25

tell application "System Events"

keystroke StarCnt using {command down}

end tell

delay 0.25

end tell

 

ExtendScript "in" Bridge

==================

if (BridgeTalk.isRunning("bridge")) {

    // Wait for AppleScript input before executing

    BridgeTalk.listen = function(msg) {

        var filePath = msg.body;

        selectFile(filePath);

    };

}

 

function selectFile(filePath) {

    var file = new File(filePath);

    if (file.exists) {

        app.document.select(file);

//       app.document.thumbnail.rating = 3; // This will be reworked once javascript works

    } else {

        alert("File not found: " + filePath);

    }

}

 

1 reply

Participant
May 23, 2025

I'll be looking into installing ExifTool to use it with AppleScript to change the "xmp: Rating #" within the JPG files so that they show up in Bridge. Alternatively, perhaps I could edit the jpg photo file directly using AppleScript to read and write to the file -- altho that could get more complicated if a checksum needs to be recalculated.

 

But if you can think of a way for me to do this directly (in a way that's very speedy) with only Bridge and Applescript, I'd like to try that out.

Participant
May 25, 2025

In case it helps someone, here's my solution:

I downloaded and installed ExifTool on my artist friend's Mac.

Using ExifTool to modify photo labels is far speedier than using the "open" Bridge command with AppleScript.

 

This is how I'm using it, and maybe it'll inspire you to try something like this:

Small photo thumbnails of paintings are held in Numbers cells (one cell per row-record) along with other info on the same row about the painting, including the path to where the photo resides on the local hard drive. User simply selects any row in Numbers (each row holds a previous show's Venue Name -- like a gallery name) , and then runs my script which includes adding colored labels to every photo file who's path is found in this Numbers database. After doing that, then using Bridge, the artist browses her hundreds of paintings, and she can see very conspicuously the xmp label-colors which are now updated for the specific venue to reveal the paintings she should NOT select for resubmission to the same venue because they were already shown there previously. Also, any paintings sold (and therefore unavailable for future shows) are updated with a unique label-color. This is far easier for her to select new painting submissions for shows than to try to memorize which paintings she saw in the Numbers database which had been shown before at that venue (partly because there are other paintings in the database for that same venue which were submitted previously but weren't accepted for the show at that time and so are available for resubmission -- adding confusion for memorizing).

 

For each photo in the Numbers list (which includes a cell holding the associated filepath to the photo), my script runs them all through the following (where "LocationVal" is my variable holding the path to the file -- and later I'll be adding the "Try" along with Error handling):

set exiftoolCommand to "/usr/local/bin/exiftool -XMP:Label=" & quoted form of (LabelColor as string) & " " & quoted form of (POSIX path of LocationVal)

-- try 

set shellResult to do shell script exiftoolCommand

--on error

--handle the error