Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Tried it in the Extend Script editor. It's telling me getFiles() is not a function?
#target "bridge"
var search_criteria="511006"
new SearchDefinition (search_criteria);
getFiles();
Copy link to clipboard
Copied
it would be something like...
#target bridge;
var files = Folder(app.document.presentationPath).getFiles("*.jpg");
alert(files.join("\n"));
This will list all jpg files in the current folder.
Copy link to clipboard
Copied
It does work on the server. Here's what I have that is working:
#target bridge;
var files = Folder("/Volumes/sblain$/*SIGNS FOR PREPRESS/Agriculture Dept/Chicken Coops/high res images").getFiles("*811951*");
alert(files);
Copy link to clipboard
Copied
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)?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
It's telling me "The variable image_search is not defined." number -2753 from "image_search"
set images_for_print_folder to "/Volumes/sblain$/IMAGES_FOR_PRINT/"
set sku_number to "R3710"
tell application "Adobe Bridge CC 2017"
activate
do javascript "
#target bridge;
search_bridge();
function search_bridge(){
//Declaring JavaScript variables
var search_folder = ['" & images_for_print_folder & "'];
var search_sku = ['" & sku_number & "'];
//Stringing together the search criteria from the sku_number
var search_criteria = ('*' + search_sku + '*');
//Telling bridge to search
var image_search = Folder(search_folder).getFiles(search_criteria);
//Displaying the search results
alert(image_search);
return image_search[0].toString();
}
"
display dialog image_search
end tell
Copy link to clipboard
Copied
Sorry can't help with appleScript.
To search sub folders, you need to get a list of all sub folders and iterate throgh them, example...
//Array to hold all sub folders
var folders =[];
var topLevel = Folder.selectDialog("Please select top level folder");
folders = FindAllFolders(topLevel, folders);
folders.unshift(topLevel);
var files = new Array();
//Iterate through all folders
for(var a in folders){
var filesFound = folders.getFiles("whatToFind");
//copy any files found into files array
for(var z in filesFound) files.push(filesFound
); //reset fileFound array
filesFound = [];
}
//List files found
alert(files.join("\n"));
//Function finds all sub folders given top level folder
function FindAllFolders( srcFolderStr, destArray) {
var fileFolderArray = Folder( srcFolderStr ).getFiles();
for ( var i = 0; i < fileFolderArray.length; i++ ) {
var fileFoldObj = fileFolderArray;
if ( fileFoldObj instanceof File ) {
} else {
destArray.push( Folder(fileFoldObj) );
FindAllFolders( fileFoldObj.toString(), destArray );
}
}
return destArray;
};
Copy link to clipboard
Copied
Discovered one more thing. Is there a way to search a folder AND all the subfolders within that folder?
set images_for_print_folder to "/Volumes/sblain$/IMAGES_FOR_PRINT/"
set vendor_images_folder to "Volumes/NAS/ECommerce/A_VENDOR SUPPLIED IMAGES/"
set sku_number to "628412"
tell application "Adobe Bridge CC 2017"
activate
do javascript "
#target bridge;
search_bridge();
function search_bridge(){
//Declaring JavaScript variables
var search_folder1 = ['" & images_for_print_folder & "'];
var search_folder2 = ['" & vendor_images_folder & "'];
var search_sku = ['" & sku_number & "'];
//Stringing together the search criteria from the sku_number
var search_criteria = ('*' + search_sku + '*');
//Displaying the search criteria
alert(search_criteria);
//Telling bridge to search
var image_search = Folder(search_folder2).getFiles(search_criteria);
//Displaying the search results
alert(image_search);
}
"
display dialog my_files as string
end tell
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more