assign keywords from excel
Copy link to clipboard
Copied
Hi there, I was wondering if anyone might have a suggestion for me: All our product images are named with a 9-digit ID number. All the item numbers and product information (name, color, gender, category, view, etc.) are stored in an Excel workbook for each photoshoot. Typically, we generate a list of keywords from the excel doc (using applescript), then import that list into Bridge before manually assigning keywords to each image. This seems like a perfect opportunity for automation. Is it possible for Bridge to open the Excel doc, find the cell with the name of the image, and assign the associated keywords from the same row? seems easy enough, but I'm not sure where to start.
-S
Copy link to clipboard
Copied
I don't think it will be possible, Bridge scripting is JavaScript only and cannot access Excel, what most do is export the details to a csv file and use that as an input file. As a general purpose import from a csv or tab delimited I have created a script here that might be of use.
http://www.ps-scripts.com/bb/viewtopic.php?f=19&t=3463&sid=068418ad7cac24ea2e16dcb02a122e20
Edit: It may be posible to run a JavaScript function from within Applescript? I can't help with AppleScript though.
Copy link to clipboard
Copied
The only thing that you can do with Bridge from an AppleScript point of view is the command 'do javascript' and pass it the code my Trial of CS5 is over so I can't even test. I think that the suggested CSV or TDT route would be best and simplest. Otherwise you will need to be constructing your Javascript syntax on the fly.
Copy link to clipboard
Copied
Could you pass variables in and out of a call to applescript? i.e. bridge sends the filename(s) to an applescript that looks up the keywords in a specified workbook, returns those keywords to bridge, which assigns them to the image.
Or I could set up a hot folder on the desktop that runs .as scripts in Excel and .jsx scripts in Bridge?
All this would be much easier if Bridge were able to run applescripts like Photoshop, Illustrator, InDesign, etc...
Copy link to clipboard
Copied
From what I've tried myself in the past is that all you get returned from 'do javascript' is the usual 'undefined' if your javascript is a 'function' that returns a value then you do get this. With the other main Adobe app's (Ps, Ai, & Id) AppleScript can execute JavaScript but NOT the other way around the Exception in that is Id which can. What you are talking about is using 2 very different scripting languages each communicating to a different app then cross referencing information. (Having an open Excel workbook serves no purpose at all, just another thing to clutter up the GUI). The solution offered by Paul only requires a simple 'save as' from Excel the data is read in then the arrays are searched by JavaScript which has access to the full Bridge DOM to process.
Only AppleScript Has Folder Actions. Bridge does have process scheduling (in CS5 can't say for others).
'do javascript' has been pretty much all that Adobe has offered AppleScript over the last 3 releases so I don't think you'll be seeing anything added in the near future either…
Copy link to clipboard
Copied
Mark, would it be possible to pass information from AppleScript into a do Javascript function? What I was thinking would be to extract a csv/tdt file using AppleScript and passing the file path to the do javascript, if that was possible everything else could be done in JavaScript?
Copy link to clipboard
Copied
I would need to take a look at the guide for Bridge I know in Ai & Ps that the command 'do javascript' has the parameter 'with arguments' which you would just use an ordered list like {"A", "B", "C"} you should then on the Javascript side just use the argument values. BTW the CS5 Bridge is still running even though my Trial has ended… I get to play some more…
Copy link to clipboard
Copied
Fair enough. I can export the data as a csv and do the lookup in Javascript. It will still be less time-consuming than tagging all the images by hand. Can you point me in the direction of the java 2D array search functions?
Copy link to clipboard
Copied
For gereral JavaScript array functionality :-
http://www.w3schools.com/js/js_obj_array.asp
There are a few examples of complete scripts here :-
http://www.ps-scripts.com/bb/viewtopic.php?f=19&t=2320&sid=ad12f973f1d32fd1d4870ebc47cbefd5
Copy link to clipboard
Copied
Paul, there is no PDF AppleScript documentation (well there would NOT be much point) here this the contents of the app's scripting dictionary…
do javascript v : Run a Javascript in Adobe Bridge.
do javascript text : The Javascript to run in Bridge.
[with arguments list of any]
→ integer : The result of running the script in Bridge.
do javascript v : Run a Javascript in Adobe Bridge.
do javascript file : The Javascript file (.jsx) to run in Bridge.
[with arguments list of any]
→ integer : The result of running the script in Bridge.
Don't be overwhelmed by all this? best looked at half at a time… So it's the same as Ps & Ai (who says that there is NO consistency in scripting these apps?) Oh that was Me…
Copy link to clipboard
Copied
here is a plain and simple to use CSV file reading function…
#target bridge var csvFile = new File('~/Desktop/ColoursCSV.csv'); if (csvFile.exists) { var fileArray = readInCSV(csvFile); alert('CSV file has ' + fileArray[0].length + ' columns…'); alert('CSV file has ' + fileArray.length + ' rows…'); } function readInCSV(fileObj) { var fileArray = new Array(); fileObj.open('r'); while(!fileObj.eof) { var thisLine = fileObj.readln(); var csvArray = thisLine.split(','); fileArray.push(csvArray); } fileObj.close(); return fileArray; }
To search you just use a for loop and when a value matches set some variables or values to the rest of that array…

