Skip to content

Instantly share code, notes, and snippets.

@natcl
Last active November 11, 2020 18:56
Show Gist options
  • Save natcl/7a5c98aae8b21475caf9 to your computer and use it in GitHub Desktop.
Save natcl/7a5c98aae8b21475caf9 to your computer and use it in GitHub Desktop.
OSX Folder Action to automatically import files added to a folder in Photos.app
property imageFiles : {"jpg", "pef", "dng", "jpeg"}
on adding folder items to theWatchedFolder after receiving theDetectedItems
repeat with theItem in theDetectedItems
set theItemPath to POSIX path of theItem
set ImageFile to POSIX file theItemPath
tell application "System Events"
if name extension of theItem is in imageFiles then
tell application "Photos"
set DestinationAlbumName to "Inbox"
if not (exists container named DestinationAlbumName) then
make new album named DestinationAlbumName
end if
import ImageFile into container named DestinationAlbumName with skip check duplicates
end tell
tell application "Finder"
delete theItem
end tell
end if
end tell
end repeat
end adding folder items to
@davidjoly
Copy link

Great Script! Eye-Fi should buy it from you! Thanks.

@natcl
Copy link
Author

natcl commented Jun 1, 2015

To setup you will need to place this file in the following folder:

/Users/your_username/Library/Workflows/Applications/Folder Actions/

You need to configure eye-fi to download new files to a folder on your computer. Once this is done, you need to right-click that folder and go into Services-->Configure Folder Actions
In that Window, make sure folder actions is enabled and choose "Import Photo" which should appear in the list.

For this to work well, Photos.app needs to be always running on the target computer.

@ccsbonn
Copy link

ccsbonn commented Jun 12, 2015

Thanks for this!
It works perfectly when I add files to the watched folder manually, but when the are automatically imported using the Eye-Fi Center, it won't do anything...
Any thoughts?

@xoda0
Copy link

xoda0 commented Jun 28, 2015

Thanks natcl for writing this! It's very useful.

Is it possible to go one step further and automatically add the newly imported images to a Shared iCloud as well?

@natcl
Copy link
Author

natcl commented Jun 28, 2015

Hello,

I'm not sure shared albums are accessible via AppleScript but you could try changing the name of the destination folder to the name of your shared album:

set DestinationAlbumName to "Shared_album_name"

@natcl
Copy link
Author

natcl commented Jun 28, 2015

I checked and I don't think shared albums are available to AppleScript sadly...

@xoda0
Copy link

xoda0 commented Jun 30, 2015

thanks for looking into it!

@StuA1
Copy link

StuA1 commented Aug 10, 2015

I don't seem to have a Library folder in the path you directed that I put the script - /Users/your_username/Library/Workflows/Applications/Folder Actions/

If I try to create a folder called Library, it says one already exists, but I can't see it using Finder. Any suggestions?

@dwhogg
Copy link

dwhogg commented Sep 19, 2015

The Library folder is a 'hidden file', so you will need to change your settings to show hidden files and folders. You can search for how to do that. It's a little obtuse :)

@JunichiIto
Copy link

FYI
My PC did not have a folder called ~/Library/Workflows, because I have never launch Automator app. After launching it, I could see ~/Library/Workflows/Applications/Folder Actions.

@FrenchKheldar
Copy link

Will this import images as referenced images if you have the option unchecked in Preferences. I made an automator script similar to that and it seems to import the pictures within the Photos library... Thanks !

@stefbelg
Copy link

stefbelg commented Mar 4, 2018

I tried to use this script to import Camera uploads (dropbox) but Photos reports that an import is already started, is there a way that the import only starts after the folder content is unchanged for x seconds?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment