Auto Sync Photos App with local folder

photos.app

I have all my pictures locally stored on my Macbook in a folder called Pictures. I use the Photos.app to search and filter my pictures.

I don't use CLoud or anything else so disabled 'Copy pictures to picture library'. Then I imported all the pictures into Photos.app.

Now when I have new pictures I copy them into my Pictures folder but Photos.app does not add those new pictures. I have to import them every time manually.

Whats the best way to get new pictures automatically into photos.app?

Best Answer

Photos.app is not designed to "sync" its contents with folders in the way you described. I don't believe it ever was, even with iPhoto. However, it's fairly easy to automate the process of importing photos into Photos.app from a chosen watched folder.

A watched folder in MacOS is one that is monitored for changes to its contents or to the files themselves. When such a change occurs, e.g. a new file is added, it triggers a Folder Action.

A Folder Action is typically an AppleScript or Automator workflow that performs a series of automated actions in response to being triggered by changes to the watched folder to which the folder action is attached.

So, simply put:

① A file is added to a specific folder ➔ ② An AppleScript is triggered to perform some actions

My suggestion would be to choose a folder you want monitored by the system, and use this folder to put your photos in to have them automatically imported into Photos.app.

I describe how to set up a folder action here (Steps 1 to 6).

This is the AppleScript that will do the importing, and to which the steps to create a folder action pertain:

    on adding folder items to ThisFolder after receiving MediaFiles

        set ListOfMediaExtensions to {"jpeg", "jpg", "tiff", "tif", "png", ¬
            "gif", "heic", "heif", "raw", "dng", "mov", "mp4", "mp4v", "m4v"}

        repeat with ThisFile in the MediaFiles
            tell application "Finder" to ¬
                if name extension of ThisFile is in the ListOfMediaExtensions then ¬
                    set the end of MediaFiles to ThisFile as alias
            set MediaFiles to the rest of MediaFiles
        end repeat

        tell application "Photos"
            run
            delay 2
            import the MediaFiles
            quit
        end tell

    end adding folder items to

It's a basic script, and folder actions and AppleScript are, of course, capable of doing a lot more (moving files, deleting files, adding photos to albums, tagging them with keywords, etc.) But in the absence of those sorts of requests, I felt it best to keep things simple and focus on getting it working.

The script does, however, include a few lines of code that filter the files added to the folder by extension name, to ensure files such as text files are ignored, and only media files (photos and videos) get imported.

You'll know the script has been successful when Photos.app sends a notification to report that a number of photos were successfully imported. But, as the script stands just now, you won't see the Photos.app appear on your screen at any point (this can be changed if you'd prefer to have it show you the imported photos).


A final couple of considerations: the way you've chosen to set up Photos.app to not copy the files into its library, but rather keep them available in Finder and merely referenced from inside the Photos.app is what's called a Referenced Library. It is worth taking a moment to read this page here on the disadvantages of a referenced library in Photos.app. Of course, you may decide that none of the drawbacks particularly affect you, and needn't concern yourself with changing your system.

Lastly, I would suggest that the folder you choose as your watched folder be different than the one you ultimately have your photos residing in. If you use the same folder, you can accidentally trigger the folder action and import duplicates (although, Photos.app does check to see if duplicates are being imported and asks you what to do in those instances). The folder action won't attempt to import files that are already in the folder, so that's not the concern; it will trigger and act upon new files added (good!), or any files that change (maybe less good!). Therefore, renaming a file, editing a photo and re-saving it, or moving it out of the folder and then back in, will all cause the folder action to trigger and act upon that file which you might not want re-imported.

You can decide what is best given your habits, and using the same "Pictures" folder as both a watched folder and the base for storage could still be done if you bear those caveats I mentioned in mind. You could always place the watched folder inside your "Pictures" folder so it's nearby to drop your new photos in.

If you use a separate folder as your "watched" folder, then you'll want to add one further line to the AppleScript that will move the files out of the watched folder so that are placed into your "Pictures" folder.

A line like this will do it:

    tell application "Finder" to move the MediaFiles to (POSIX file "/path/to/pictures/folder" as alias)

If you've any questions or need more help, leave a comment and I'l get back to you.