do javascript error Bridge 2025, alternative ways?
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);
}
}
