0

I'm trying to fully automate a workflow for getting images into iPhoto. The last piece of the puzzle is handling duplicate images. Currently I see no way in Applescripts import command to not import duplicates. Therefore when a duplicate arrises all workflow stops and iPhoto waits for input.

Is there a way to get through this?

1 Answers1

1

You will need to script this. Here is a bit of code that seems to work inside applescript editor. Adjust accordingly for automator...

set iFolder to (choose folder)

set iFiles to (list folder iFolder)

tell application "iPhoto"
    repeat with iFile in iFiles
        try
            set pFound to get (every photo of album "Photos" whose image filename is iFile)
        end try
        if length of pFound is not 0 then
            log ("File '" & iFile as text) & "' exists..."

            # Move or delete it here
        end if
    end repeat

    # Continue with import
    import from (iFolder as alias)
end tell
Dude named Ben
  • 507
  • 3
  • 16
  • This seems to be assuming that images with only be duplicates if they have the same name, and all photos with the same name are duplicates. Since both of these assumptions will fail, how to really tell if there is a duplicate? (How does iPhoto know which images it has already imported when you do it from the UI?) – Michael Apr 23 '17 at 15:05
  • `execution error: The variable pFound is not defined.` – Michael Apr 30 '17 at 16:30
  • `210:215: script error: Expected class name but found identifier. (-2741)` – Michael Apr 30 '17 at 16:49