Passing Information to Excel

Hello,

Trying to work on one of my first semi-complex AppleScript. I need to open a file, add Metadata based on what the file’s name is, and then close/save the file. An example of the file naming schema is something like SKU-Color-Year-Vendor.jpg. The color is an abbreviation, so it would have to look-up the actual color in an external table, which can be edited by a user. An example of the table would be like (Boys, Boysenberry / Yel, Yellow / Mar, Maroon), and an example file name might be: 1115-Peri-99-rdmVendor.jpg.

I was trying to come up with the best way to automate this process, and I was thinking something along the lines of:

Applescript tells excel to open the file(s)
Applescript passes parameter(file name) to an Excel Macro
Excel Macro runs and inserts necessary Metadata based on the received parameter
Excel Macro has to look up values in another file, a user table that has abbreviations.
AppleScript waits for operation to occur
Macro passes back a value to AppleScript indicating it has finished
AppleScript closes the file

Not looking for code to do this, just thoughts on the process.
To me, this entire process seems too clunky, and like too much is going on for an Applescript. Does anyone share those thoughts? Can you think of a better process flow for this operation?

Thanks for your thoughts.

My thought is that Excel should do as much of the processing as possible.

“Excel Macro has to look up values in another file, a user table that has abbreviations.”

  1. It would be easiest if the user table was in an Excel file. Perhaps in a hidden worksheet

  2. If Excel Macros (VBA) are a available, it should be used rather than applescript. It is faster and the MacScript command makes all of AppleScript available to VBA, (the revers is not the case)

The problem is that these things are images. I haven’t tested editing them and saving them in excel, but they definitely wouldn’t have a hidden worksheet in them.

Are you trying to work with the images themselves or with data in the images (e.g. a screen shot)?

I am trying to work with the data stored within the image file – the XML. I’m just trying to add meta data to this xml within the files based on what data the file name of the file contains.

Thanks Mike

I have no idea where you are going with this.

You have an image file (JPG?)

I gather that you are not intersted in working with an image of the character “12” (for example), but with the compression/resolution/JPGish data that is also stored in the image file. (The word “JPGish” is intended to convey my lack of experience with image files.)

I’m guessing that that data can be extracted using a script that tells the “Image Events” application what to do. And that, after manipulation, the data can be inserted the same way.

Where Excel comes in is in the manipulation of the data.

Is that the case?

hmm, interesting. I was not aware of the Image Events app within AppleScript. It looks as though it can edit metadata as well. I don’t suppose you could tell me if you can write to a non-standard metadata field? I just did a generic read and it appears to only read…
samplesPerPixel, hasAlpha, dpiHeight, dpiWidth, bitsPerSample, profile, formatOptions, ExifColorSapce, pixelHeight, path, creation, software, space, pixelWidth, format, make, model, and typeIdentifier. A thought I had was writing to the metadata via JavaScript, but I’m not sure on the how - how to execute JavaScript on an image from an ApplesSript.

Also, I made a reeeally stupid mistake of closing my script after I’d written it and only saved it as an application/read only. I’m guessing it means just that, there is no way to get back the ‘script contents’. I don’t suppose you know a way around that?

Well I think I’ve got my solution, but I am still stuck on a point. ExifTool can write to custom XMP fields:
http://www.sno.phy.queensu.ca/~phil/exiftool/

I’m getting stuck on how to correctly add fields in its config file, see: http://www.sno.phy.queensu.ca/~phil/exiftool/config.html

Mine looks something like:
%Image::ExifTool::UserDefined::xxx = (
GROUPS => { 0 => ‘XMP’, 1 => ‘XMP-xklc’, 2 => ‘Image’ },
NAMESPACE => { ‘xklc’ => ‘schemaurlishere’ },
WRITABLE => ‘string’,
# replace “NewXMPxxxTag1” with your own tag name (ie. “MyTag”)
Sku => { },
Pattern => { },
Style => { },
Original_Filename => { }
# XMP structures are defined as SubDirectory’s

# structure elements must be defined as separate tags.  The tag ID's
# are the concatination of the structure tag ID with the ID of each
# structure element in turn.  The list flag should be set if the
# parent structure is contained in a list.

);

(so I want to add, Sku, Pattern, Style, and Original_Filename to xmp-xklc)
I don’t understand what the “2 => Image” is referencing, and furthermore, my tags don’t seem to be created. When I attempt to write: exiftool -v2 -Sku=11 at the command line, it says the tag doesn’t exist. Any thoughts on how I’m fubar’ing the syntax here?

Thanks for taking the time.

I was able to finish/fix this by myself, just a bit more trial and error. If anyone has any q’s, feel free to ask. Thanks for pointing me in the right direction, Mike.