Skip to content

Instantly share code, notes, and snippets.

@Jonty
Created December 27, 2014 22:27
Show Gist options
  • Save Jonty/13710046bf07263a61b1 to your computer and use it in GitHub Desktop.
Save Jonty/13710046bf07263a61b1 to your computer and use it in GitHub Desktop.
An bit of Applescript for use in Automator workflows that takes a list of files and returns a list of files that do not exist in your iPhoto library already, to prevent duplicates being imported.
on run {input, parameters}
set allFiles to input
set newPhotos to {}
tell application "iPhoto"
repeat with aFile in allFiles
try
set fileInfo to info for aFile
set actualFileName to name of fileInfo
set photosFound to get (every photo of album "Photos" whose image filename is actualFileName)
end try
if length of photosFound is 0 then
set newPhotos to newPhotos & {aFile as alias}
end if
end repeat
end tell
return newPhotos
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment