Skip to main content
mBornbach
Known Participant
May 1, 2017
Question

Script to Search with Bridge

  • May 1, 2017
  • 2 replies
  • 2320 views

I'm attempting to script searching Adobe Bridge. I'm not real familiar with JavaScript. If anyone could please give me an idea of how to search Bridge, it would be much appreciated!

set my_folder to "/Users/user_name/Desktop/"
set my_search_criteria to "612369"

tell application "Adobe Bridge CC 2014"
    activate
   
    do javascript "
                #target 'bridge'
//Declaring the variables for the folder and search criteria
var search_folder = ['' & my_folder & ''];
var search_criteria = ['' & my_search_criteria & ''];

new SearchCriteria (searchField, operandType,
*searchFieldDisplay, *operands);

new SearchDefinition (criteriaList, defaultResultsLimit,
*ranks, *scopeSpecifiers);

new SearchSpecification (conditionList, conjunction, maximumResults,
rankOrdering, rankField, scopeSpecifiers);

obj.getBridgeURIForSearch
(scope, specification)

obj.getSearchDetails ()

/**/"

end tell

This topic has been closed for replies.

2 replies

Stephen Marsh
Community Expert
Community Expert
May 2, 2017

Yet another option would be to use the CLI based ExifTool to search an available path. What criteria are you using for the find (I can’t script, so I can sort of work it looking at your code, can you post a screenshot of the find gui)?

mBornbach
mBornbachAuthor
Known Participant
May 2, 2017

The JavaScript/Bridge search is working and the AppleScript variables are being passed to JavaScript successfully. The only thing I need to figure out now is how to pass the JavaScript search results back to AppleScript. This script will display the JavaScript alert showing me the search results, but it displays a variable undefined error when I display a dialog with the search results back in AppleScript.

Thank you both! I'm learning a lot about working with JavaScript.

--d--

--Declaring the search folder and the sku_number variables in AppleScript

--There is more AppleScript code that gets each sku number and other info from an Excel file, but that part works so I'm not posting it.

set high_res_folder to "/Volumes/sblain$/*SIGNS FOR PREPRESS/Agriculture Dept/Chicken Coops/high res images/"

set sku_number to "811951"

--Activating Bridge

tell application "Adobe Bridge CC 2017"

  activate

  do javascript "

  #target bridge;

  search_bridge();

  function search_bridge(){

  //Declaring JavaScript variables

  var search_folder = ['" & high_res_folder & "'];

  var search_sku = ['" & sku_number & "'];

  //Concetanating the search criteria with asterisks and the sku_number

  var search_criteria = ('*' + search_sku + '*');

//Telling Bridge to search

var my_files = Folder(search_folder).getFiles(search_criteria);

//Displaying the search results

alert(my_files);

//Attempting to return my_files to pass the variable back to AppleScript (not working so far)

return my_files;

}

"

--Displaying a dialog to see if the search results variable has been passed to AppleScript (no, not working)

  display dialog my_files as string

end tell

SuperMerlin
Inspiring
May 2, 2017

my_files is an array not a string.

You could test with:

return my_files[0].toString();

This will return the first file in the array as a string.

SuperMerlin
Inspiring
May 1, 2017

Sorry but Bridge is JavaScript only!

Edit, why Bridge? you could use Photoshop, then you could use appleScript, unless there is a reason for Bridge?

mBornbach
mBornbachAuthor
Known Participant
May 1, 2017

What I'm trying to do is search an smb connected server for images. I tried shell script "find" and "mdfind" and it was very slow. However, searching by hand in Bridge is much faster. Since, there would be hundreds of images to search for by hand several times a week, I figured it would make a lot of sense to script searching for images in Bridge.

P.S. Is it possible to search a connected server with Photoshop? I see where it searches Photoshop, Adobe Stock, etc., but that part isn't giving me an option to select and search any servers.

SuperMerlin
Inspiring
May 1, 2017

There would be no difference between Bridge or Photoshop using javeScript as it would be the same code using getFiles().

Servers are not supported by Adobe, so all I can say is try and see if it works on your system.