Thanks again both. I have a bit more work to do on this but I think I'm heading for a solution that generates a comma-separated list of values, pretty much as you suggest, but which I can then use immediately in SQL INSERT statement. The gist of it - I think - will be (bash) shell script something like ...
Code: Select all
EXIF_values=$(identify -format "'%[EXIF:make]','%[EXIF:model]','%[EXIF:FNumber]',%[EXIF:ExposureTime],%[EXIF:ISOSpeedRatings],'%[EXIF:DateTimeOriginal]'" $item)
INSERT INTO table_photos (make, model, Aperture, etc ...) VALUES ($EXIF_values)
(where $item is the current file at each step in the loop). The string $EXIF_values should expand into the list that the SQL command needs - so long as I make sure I have them in the right order! SQL does need some of the values enclosed in quotes, but that doesn't seem to be an issue as the IM command happily allows me to insert single quotes.
Thanks for the tip about other %-escapes. I'll be using some of them although probably not filename because many of those in this case do contain commas (this is my main reason at the moment for not going for the csv approach).
I had thought about using a PHP script for this, and may still do if it gets much more complicated. I need to error trap stray non-image files that might have found their way into the main folder structure (easy enough), and there are quite a lot of images in the set that are scanned 35mm negatives, so won't have some of the EXIF data that I'll be storing for digital camera images. I think the approach above will cope with those, but I need to test some permutations. It looks like IM throws an error message like '
identify: unknown image property "%[EXIF:FNumber]" @ warning/property.c/InterpretImageProperties/3597.' for the scanner files, but the $EXIF_data string that I'm generating seems just to contain empty strings between commas, so I think I'll be able to use it. If not, then the string does seem to contain the scanner make/model, so I can test for that and generate a modified $EXIF_values string if necessary.
Many thanks again.