Local Links

External Links


Search this site

Getting rid of the JPEG duplicates when importing RAW images with iPhoto

Note: This article is a bit outdated. I've improved the scripts since this post and have made them available on this separate page: AppleScripts for iPhoto.


My camera can take RAW pictures, and can also store them in both a RAW and a JPG format (i.e. RAW+). This is, for instance, convenient when importing the pictures onto an iPad as the iPad doesn't need to decode the RAW pictures then on its own, which would be rather slow.

When I later import these pictures from the iPad onto my Mac using iPhoto, I end up with duplicate items for each picture (the iPad groups them nicely together and shows only one item). This means that I see each picture twice in the iPhoto browser. I hope that Apple will eventually make iPhoto as smart as the Photos app on the iPad, by showing grouping the two formats for the same picture automatically. But until then, I like to tidy those dupes up myself.

So I needed a way to separate the RAW files from their JPG twins. However, while iPhoto lets me search for items with a specific keyword (here: Raw), it seems to offer no way to find items not having a particular keyword, nor a way to invert a selection.

I also tried Automator, which offer the "Filter iPhoto Photos" action, but that one seems to have a bug (as of July 2010) in which its "is not" operator for searching keywords doesn't work either.

So I had to write an AppleScript.

How to find the non-RAW files in iPhoto

I've written a script that looks at all currently selected items in iPhoto and finds those that do not have the "Raw" keyword. Those then get assigned the "non-row" keyword.

With that "non-raw" keyword, iPhoto lets me find these items easily so that I can, for instance, delete them, as I still have the RAW versions (I have to make sure, though, that I really do still have the RAW versions, as the script won't check that!).

Here's the AppleScript code. To install it, simply launch "AppleScript Editor" and paste the following code in, then save it as File Format: Application. To use it, first select your pictures of which you want to identify the non-RAW versions, and then run this script or application. You can then even view its progress in iPhoto, where it adds the keywords to all non-Raw pictures you had selected.

    on run
      tell application "iPhoto"

        set selectedPictures to selection

        -- look at every selected picture
        repeat with img in selectedPictures

          -- check if the picture has a "Raw" keyword
          set isRaw to false
          set kws to keywords of img
          repeat with kw in kws
            if name of kw is equal to "Raw" then
              set isRaw to true
            end if
          end repeat

          -- add the "non-raw" keyword if the picture is not a raw picture
          if not isRaw then
            select img
            assign keyword string "non-raw"
          end if

        end repeat
      end tell
    end run

I'm sure the checking for "Raw" keywords can be improved, as well as the script could collect all non-raw items first, finally set the selection and keyword only once. But I'm pretty bad with AppleScript, so I didn't want to spend another 2 hours getting this work. If you have improvement suggestions, please write me an e-mail and I'll update it here.

Page last modified on 2013-02-11, 22:43 UTC (do)
Powered by PmWiki