Automatically Sync PhotoStream to Dropbox

The sync behind Apple’s photostream is really comfortable. My photos are uploaded when my iPhone has WiFi and my mac downloads them instantly. So when I want to get an image from my phone I just have to tap into the PhotoStream.

But all regular solutions are in some way inconvenient. To access the PhotoStream you have to use the somewhat bloated iPhoto and Dropbox requires you to either start the iOS app or connect your iPhone via USB. None of these options are really comfortable.

Digging into Photostream

Turns out OS X saves the images as regular files, but puts each in a separate subfolder – not that cool for direct use. But at least that’s automatically done by a system service, so no need for iPhoto.

In a quick Google search I found an AppleScript that copies images from the PhotoStream to the Dropbox folder. That seemed great until I noticed it freezes the Finder for the duration of the sync.

Copying the PhotoStream into your Dropbox

That’s why I came up a little bash script that does the same but it runs faster and doesn’t freeze the Finder. You can find it below or on GitHub Gist.

The script just takes all files starting with IMG_ from the PhotoStream folder and copies them into the subfolder photostream of my Dropbox. Make sure you adjust the second path and make the script executable.

cd ~/Library/Application\ Support/iLifeAssetManagement/assets/sub/
find . -name 'IMG_*' -exec cp -n -p {} /Volumes/HDD/max/Dropbox/photostream \;

Additionally I registered the script as a LaunchAgent, so it automatically gets started every 5 minutes. Again, make sure you adjust the paths and save the .plist-File (is.justcurious.photostreamsync.plist) in ~/Library/LaunchAgents/ . (A restart is required to actually register the LaunchAgent.)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>is.justcurious.photostreamsync</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Applications/utils/photostream</string>
    </array>
    <key>StartInterval</key>
    <integer>300</integer>
</dict>
</plist>