How to get EXIF-ISO filmspeed from Nikon NEF files using AppleScript?

I tried, and tried using iMagine Photo, but ISO speed works only for some Nikon camera files, and not others. Unfortunately the one I’m interested in (D70) it doesn’t work for.

I’ve taken a gander at Image Events, but it doesn’t seem to be there, despite the fact that Apple obviously knows how to get that info using Aperture (which I don’t have). I’ve experimented with graphic converter, but have not found the magic bullet. I’ve looked at a ton of other EXIF display programs, but few work with both JPEG and NEF, and allow extracting a single value using AppleScript.


You can do it with a shell script:

set a to choose file with prompt "Select a file for which you would like the ISO:"
set b to paragraph 2 of (do shell script "mdls -name kMDItemISOSpeed " & quoted form of POSIX path of a)

-->"kMDItemISOSpeed = 800"

There are very good ways of parsing out just the ISO information, but I am not very skilled with that.

That’s interesting you got a real result and I just get dashes when running the command line part by itself. If I run the Applescript, it gets an error saying there is no paragraph 2. I tried the cmd line on a set of sample files which includes D80, D70, D200 and Coolpix5000 NEF files.

I’m running 10.4.9.

Is there some other component I need to install? Does this depend on Spotlight being turned on?




Yes, the mdls shell command relies upon Spotlight information (I believe that it is the UNIX side of Spotlight), so your images need to reside in directories that are actively being indexed by Spotlight. The paragraph 2 portion of my script simply reduces this:

"/Users/praxisii/Pictures/2007/Originals/2007/Roll 34/DSC_0026.JPG ------------- kMDItemISOSpeed = 800"
to this:

"kMDItemISOSpeed = 800"

This modification will return the entire reply from the shell:

set a to choose file with prompt "Select a file for which you would like the ISO:"
set b to (do shell script "mdls -name kMDItemISOSpeed " & quoted form of POSIX path of a)

I use iPhoto a lot, and the only thing I have noticed that may help is that this will only work on the orginal or modified files of a photo, NOT on the thumbnail image files that iPhoto generates. I use a Nikon D70s, iPhoto, and Spotlight is on for my entire system. If you want to see how much Spotlight data is available for a particular photo file, try this:

set a to choose file with prompt "Select a file for which you would like the ISO:"
set b to (do shell script "mdls  " & quoted form of POSIX path of a)

-->"/Users/praxisii/Pictures/2007/Originals/2007/Roll 34/DSC_0026.JPG -------------
kMDItemAcquisitionMake         = \"NIKON CORPORATION\"
kMDItemAcquisitionModel        = \"NIKON D70s\"
kMDItemAttributeChangeDate     = 2007-06-18 08:00:38 -0700
kMDItemBitsPerSample           = 32
kMDItemColorSpace              = \"RGB\"
kMDItemComment                 = \"                                    \"
kMDItemContentCreationDate     = 2007-05-23 09:37:37 -0700
kMDItemContentModificationDate = 2007-05-23 09:37:37 -0700
kMDItemContentType             = \"public.jpeg\"
kMDItemContentTypeTree         = (\"public.jpeg\", \"public.image\", \"\", \"public.item\", \"public.content\")
kMDItemCreator                 = \"Ver.1.00 \"
kMDItemDisplayName             = \"DSC_0026.JPG\"
kMDItemEXIFVersion             = \"2.2.1\"
kMDItemExposureMode            = 0
kMDItemExposureTimeSeconds     = 0.01666667
kMDItemFlashOnOff              = 1
kMDItemFocalLength             = 35
kMDItemFSContentChangeDate     = 2007-05-23 09:37:37 -0700
kMDItemFSCreationDate          = 2007-05-23 09:37:37 -0700
kMDItemFSCreatorCode           = 0
kMDItemFSFinderFlags           = 0
kMDItemFSInvisible             = 0
kMDItemFSIsExtensionHidden     = 0
kMDItemFSLabel                 = 0
kMDItemFSName                  = \"DSC_0026.JPG\"
kMDItemFSNodeCount             = 0
kMDItemFSOwnerGroupID          = 501
kMDItemFSOwnerUserID           = 501
kMDItemFSSize                  = 2471212
kMDItemFSTypeCode              = 0
kMDItemHasAlphaChannel         = 0
kMDItemID                      = 1912541
kMDItemISOSpeed                = 800
kMDItemKind                    = \"JPEG Image\"
kMDItemLastUsedDate            = 2007-06-18 08:00:38 -0700
kMDItemOrientation             = 0
kMDItemPixelHeight             = 2000
kMDItemPixelWidth              = 3008
kMDItemProfileName             = \"Camera RGB Profile\"
kMDItemRedEyeOnOff             = 0
kMDItemResolutionHeightDPI     = 300
kMDItemResolutionWidthDPI      = 300
kMDItemUsedDates               = (2007-05-23 09:37:37 -0700, 2007-06-17 17:00:00 -0700)
kMDItemWhiteBalance            = 0"

Thanks for the very helpful replies.

To be bulletproof, I should probably put a check in my Applescript to detect if Spotlight is off for the volume in question, and raise an alert if it is. There are good reasons to turn it off, such as Spotlight seems to make it impossible for Disk Utility to repair the volume for errors as it cannot dismount it due to the Spotlight indexer having the volume open.



I found the command line utility jhead, here:

You can download the precompiled binary for OS-X or just compile it with fink. It would be a more robust solution and does not depend on spotlight being active. It seems the author was interested in the non image data relating to the camera settngs.


Browser: Safari 412
Operating System: Mac OS X (10.4)