Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.7: Auto-copy Photo Stream images to a folder System 10.7
To get the Photo Stream working on my MacBook I found out that I had to BUY an upgrade for an application that I don't want: iPhoto.

Looking for a solution I found that iPhoto stores its pictures in a specific location and the Photo Stream is updated even if iPhoto is not running. The goal was to create a script that copies all of the images from many sub-directories into a single folder.

As there are many people who know a lot more about OSX I would welcome improvements and feedback. Some areas to look at:
  • Using 'without replacing' which would only copy the missing pictures.
  • A Folder action which monitors changes and runs the script automatically.
Here's the script:
tell application "Finder"
  set this_folder to "Macintosh HD:Users:duittenb:Library:Application Support:iLifeAssetManagement:assets" as alias
  set target_folder to "Macintosh HD:Users:user:Pictures:MyStream" as alias
  try
    duplicate (every file of the entire contents of this_folder whose name contains "IMG") to the target_folder with replacing
  end try
end tell
Instructions

Replace the target_folder path (underlined above) with your actual destination folder. You can save the script as an application in your /Applications folder or to your Scripts menu.

[crarko adds: Note that you'll also need to modify the this_folder path if your boot drive isn't named 'Macintosh HD.']
    •    
  • Currently 3.00 / 5
  You rated: 3 / 5 (5 votes cast)
 
[21,203 views]  

10.7: Auto-copy Photo Stream images to a folder | 28 comments | Create New Account
Click here to return to the '10.7: Auto-copy Photo Stream images to a folder' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.7: Auto-copy Photo Stream images to a folder
Authored by: dfbills on Feb 03, '12 08:03:06AM

I'm surprised that iCloud will stream the photos if you don't have the current iPhoto installed. On my machine, you can't enable the feature in the iCloud System Pane.

---
-d



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: morespace54 on Feb 06, '12 01:25:27PM

Me too. I can't even enable it (from iCloud pref pane). Maybe pictures are stored in Library anyhow (which would be weird since that would mean there's no real way to turn that feature off completely). Maybe I'm missing something 'tho...



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: nicadomi on Feb 08, '12 06:58:26PM
Agreed. I don't even see the folder iLifeAssetManagement anywhere on my computer.

[ Reply to This | # ]
Re: 10.7: Auto-copy Photo Stream images to a folder
Authored by: Uncle Asad on Feb 03, '12 01:55:47PM
Since you're looking for improvements and feedback, here's a tip I hope you'll be able to employ: instead of writing hard-coded paths that users have to edit to match their username and whatnot, you can use the "path to _foo_ from _bar_ domain" constructs (with user, system, and network as domains). In this case:
tell application "Finder"
	set this_folder to (path to application support from user domain as string) & "iLifeAssetManagement:assets" as alias
	set target_folder to (path to pictures folder from user domain as string) & "MyStream" as alias
	[rest of script]
end tell
So for this script, the user only needs to change "MyStream" to the desired destination folder (and that can be set to be prompted for once at first execution and stored, so no editing would ever be required); no editing usernames or disk names required. If you're not already familiar with it, MacScripter.net has great resources and a great community to help new and experienced AppleScripters alike. Happy AppleScripting :-)

[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: arcticmac on Feb 04, '12 01:28:52AM

Just for the instructive value, this is also pretty easy to do on the command line with 'find' (for looking for files) and 'xargs' (for executing the copy). Now, if what you're after is to copy the files, then you want something like

find srcdir -iname *img* -print0 | xargs -0 -J % cp % destdir

But it might be more elegant (no idea how it works with iCloud) to use symlinks instead:

find srcdir -iname *img* -print0 | xargs -0 -J % ln -s % destdir

Basically, what this does is to use 'find' to locate files whose name matches the regular expression *img* (case insensitive, since I used -iname instead of -name), and then sends them to xargs, which takes them in batches and executes cp or ln -s with them. the "-print0"/"-0" pair is important when filenames have spaces in them, which they often do.

For bonus points, this should even work with mdfind, in case you want to take advantage of a your spotlight index to do even more advanced searches.



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: gurb on Feb 04, '12 05:35:40PM
Interesting, and a very nice tip. Kudos to DJF3.
I guess if your $HOME variable points to the right place you can do without srcdir and use:

find $HOME/Library/Application\ Support/iLifeAssetManagement/assets -iname *img* -print0

Now you can xargs to copy into ~/Pictures which should be empty, right (C:

[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: Trumpetto on Feb 04, '12 04:53:36AM

Can anyone tell me where Aperture keeps the Photo Stream pictures?

Thanks



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: jhollington on Feb 08, '12 08:06:40AM

Same place. Seems that it's the OS X iCloud components that populate this folder, and when you start up iPhoto and/or Aperture they simply suck in whatever they find there.



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: TonyT on Feb 04, '12 08:47:52AM

"[crarko adds: Note that you'll also need to modify the this_folder path if your boot drive isn't named 'Macintosh HD.']"

Come on cracko!, what about "duittenb" after Users?
You should know better, and the right answer is not to modify the path, but to use "path to library folder as string":
set this_folder to ((path to library folder as string) & "Application Support:iLifeAssetManagement:assets") as alias



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: MalEbenSo on Feb 04, '12 11:22:17PM
I have tried to wrap my head around if this can be modified to receive a Photostream from another iCloud-account (my wife's). I don't think so.

We would like to share one account for photos. However she uses a different iCloud account from mine for her addresses etc.
We cannot configure different accounts for Photostream and everything else, nor can I subscribe to somebody elses Photostream.
So to download the pictures from her iPhone to my/our Mac, on the Mac I have to keep an otherwise unused user account running in the background with iPhoto open. Not exactly ideal.

Alternatively: Her iPhone backs up wirelessly to my iTunes. Can her photos be extracted from this backup somehow?

[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: jhollington on Feb 08, '12 08:15:31AM

Unfortunately, I don't think there's any way around this, since all this script is doing is reading images from a folder that is being created and maintained by the OS X Photo Stream components -- it's actually a fairly basic script that's not doing anything much more magical than copying files from one folder to another :)

However, what my wife and I do for sharing Photo Stream while maintaining separate iCloud data is to simply use a secondary iCloud account for the other data. So on my wife's iPhone, she logs into a "shared" iCloud account as her primary account (basically mine in our case, but it could just as easily be a third "family" account), but doesn't use that for Contacts, Calendars, Reminders, Mail, etc. Instead, she has a secondary, personal iCloud account on the device for that data.

The downside to this is that it means other primary iCloud services (e.g. Documents and Data and Backups) will only be available on the primary account. Other services can be enabled on the secondary account; Bookmark sync and Find my iPhone can only be enabled on *one* account, although it doesn't need to be the primary one.

The ability to share other services across more than one account also provides for features like having a shared address book -- you could conceivably create a third "family" iCloud account with a set of common contacts and then toggle that on for all of your devices in addition to your personal contacts from your own iCloud account.



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: MalEbenSo on Feb 09, '12 02:00:39PM

Thank you for this. If we could setup a "shared account" and use it alongside our private accounts, that would be great.

I am afraid however, that I am missing something regarding implementation: When I go to iCloud in System Preferences on my Mac or on the iPhone, I can enter exactly one account. As far as I understand, this is how Apple designed it. They do not want people to use more than one account per device.



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: jhollington on Feb 10, '12 06:40:00AM

Actually, you can setup additional iCloud accounts, but it's not obvious as the default iCloud settings are only for the single, primary iCloud account. However, this is really just a shortcut to the primary iCloud account settings -- if you go into the "Mail, Contacts, Calendars" section in the iOS Settings app or the OS X System Preferences you'll see that your iCloud account is also listed there along with any other accounts you have setup. You can add an additional iCloud account from here in the same manner as you would any other e-mail, contact or calendar account.

The second account on iOS will be limited to only those features that can be used on a secondary account -- Mail, Contacts, Calendars, Reminders, Bookmarks, Notes and Find My iPhone. Note that Bookmarks and Find My iPhone can be used on a secondary account, but can only be used on ONE account at a time, so enabling them on the secondary account will disable them on the primary.

It's also a little bit different on OS X, where the second account can only be used for Mail (which includes Notes), Contacts and Calendar (which include Reminders). Bookmarks and Find My Mac can only be used with the primary iCloud account on OS X.




[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: eyer on Feb 07, '12 06:58:14AM
I like this hint's idea and the commenters implementation with find. Here's what I came up with to poll every 20 seconds and put any new images in my downloads folder:
  1. A bash script that retrieves all new photo stream images from ~/Library/Application Support/iLifeAssetManagement/assets/
    #!/bin/bash
    #
    # save as ~/.streamtimeupdate
    
    find ~/Library/Application\ Support/iLifeAssetManagement/assets/ -newer ~/Downloads/.streamtime -iname *img* -print0 | xargs -0 -J % ln % ~/Downloads/
    touch ~/Downloads/.streamtime
  2. ~/LaunchAgents/us.eyer.streamtime.plist, which runs ~/.streamtimeupdate every 20 seconds.
    <?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>us.eyer.streamtime</string>
    	<key>ProgramArguments</key>
    	<array>
    		<string>/Users/username/.streamtimeupdate</string>
    	</array>
    	<key>StartInterval</key>
    	<integer>20</integer>
    </dict>
    </plist>
Any suggestions for improvement?

[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: arcticmac on Feb 09, '12 07:25:32AM

Interesting with the use of 'ln' instead of 'ln -s'.

Considerably more work, but also considerably more sexy would be to write a little program (it would have to be complied rather than a script) that uses FSEvents to monitor that path instead of polling. But then you'd have to write some source code and compile it, and all... more effort than I want to go through right now.



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: brianpratt on Feb 10, '12 07:32:34AM
Rather than running a script every 20 seconds, I set up a Folder Action on ~/Library/Application Support/iLifeAssetManagement/assets/sub from within Automator. The only thing in the workflow is a "Run Shell Script" Action with the following contents:
sleep 30 mkdir -p $HOME/Pictures/Photostream find $HOME/Library/Application\ Support/iLifeAssetManagement/assets/sub -iname *img* -print0 | xargs -0 -J % cp -n % $HOME/Pictures/Photostream
The "sleep" is to give time for the images to finish copying in (I couldn't get the "Wait for Files to Copy" action to work how I wanted). I chose to copy files (without overwriting old ones) but you could use symlinks as well with "ln -s" instead of "cp -n". I found that viewing the ~/Pictures/Photostream/ folder with symlinks in it is less than satisfying since the preview icons are generic link images instead of my images.

[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: DJF3 on Jan 29, '13 03:17:45AM

The only issue I have with this is that the copied files get the copy-date.. Would like the copied files to keep the <b>original file date</b>

Any idea how that could be done?



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: DJF3 on Jan 31, '13 10:13:20AM

I might have found it..

Add '-p' to the cp command. -p will preserve a lot of things (see 'man cp')

Will test it in the next few days
DJ



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: bigj on Feb 07, '12 12:09:43PM

It is simple to write a folder action script with Automator that watches the folder ~/Library/Application Support/iLifeAssetManagement/assets/sub and when a new photo is added it is imported into an iPhoto album called PhotoStream. I have PhotoStream turned on in Aperture but I have an earlier version of iPhoto which does not support PhotoStream. I assume the script would also work with the latest PhotoStream supporting iPhoto.
There are two other folders - pub and watch - I do not know what these do.



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: jhollington on Feb 08, '12 08:09:21AM

Not sure about "watch" but "pub" is for photos that are added to iPhoto or Aperture and waiting to be uploaded to Photo Stream. As with the import process, it seems that neither application actually communicates with iCloud directly -- there merely read and write to the appropriate folders and then the OS X iCloud components take care of the Photo Stream interaction.



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: petebocken on Feb 10, '12 06:50:01AM

I've been trying to get this to work and can't seem to. Every time I do anything with this "sub" folder in Automator it always gives results back of the images but also the folders inside "sub" which are random numbers and letters. Can't seem to filter out just the images.



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: thesillyrabbit on Feb 08, '12 10:14:55AM

DO you have to run it each time you log out? if not how do you stop it?



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: peterb43 on Feb 09, '12 07:29:36PM

I entered the code (as modified by Uncle Asad) but it hangs Finder every time - I have to relaunch.
This is the code as entered:

tell application "Finder"
set this_folder to (path to application support from user domain as string) & "iLifeAssetManagement:assets" as alias
set target_folder to (path to pictures folder from user domain as string) & "MyStream" as alias
try
duplicate (every file of the entire contents of this_folder whose name contains "IMG") to the target_folder with replacing
end try
end tell

I get this error:
tell application "Finder"
path to application support from user domain as string
path to pictures folder from user domain as string
-- 'core'\'clon'{ 'insh':'alis'($00000000016E000200010C4D6163696E746F7368204844000000000000000000000000000000CB59B162482B0000000E2FB7084D7953747265616D0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000131D7DCB5AD85D0000000000000000FFFFFFFF00000920000000000000000000000000000000085069637475726573001000080000CB5916B20000001100080000CB5A3DAD00000001000C000E2FB7000C3E47000C379E000200344D6163696E746F73682048443A55736572733A00706574657262616
end tell

Anyone else finding this? Any ideas what has gone wrong? Thanks.



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder
Authored by: bigj on Feb 13, '12 02:47:46PM

My Folder Action Automator script which is attached to the directory ~/Library/Applications Support/iLifeAssetManagemenrt/assets/sub has three components:
1) Get Folder Contents (the "Repeat....? box is not ticked)
2) Import Files into iPhoto. I set an existing album which I call PhotoStream. (I created this in iPhoto first.)
3) Copy Finder Items. This step is not needed but I use it to check the script has run OK.

I agree that when each picture is added it is in a subdirectory with a 42 hex digit name. I guess this might be a encoded date but I don't know. My script picks up the .jpg file correctly although it only picks up the first file added in any batch. I haven't fixed this yet.



[ Reply to This | # ]
Just use a saved search in Finder
Authored by: joh on Feb 24, '12 04:28:53AM

A few nice ideas here, but the most simple way to get easily at your Photo Stream without iPhoto is to create a smart folder (saved search) in Finder with kind JPEG in the assets/sub folder. Easily accessible from the side bar, with preview icons and everything. You can even set sorting order and display type there and it will stick.



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder Corrected
Authored by: zo219 on May 02, '12 07:12:44PM

Corrected script, saved as an app to Pictures Folder, works like a dream. Name the folder, which you must create first in PIctures, whatever you want. (OP lacked full path and correct name, assets:sub, and name contains "jpg"
And input, of course, the name of your HD>

tell application "Finder"
set this_folder to "name HD:Users:name:Library:Application Support:iLifeAssetManagement:assets:sub" as alias
set target_folder to "name HD:Users:name:Pictures:Photostream" as alias
try
duplicate (every file of the entire contents of this_folder whose name contains "jpg") to the target_folder with replacing
end try
end tell



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder Corrected
Authored by: teslabolt on Oct 24, '12 09:10:20PM

Stupid question, where do I find the "name of my HD"?

"And input, of course, the name of your HD"



[ Reply to This | # ]
10.7: Auto-copy Photo Stream images to a folder Corrected
Authored by: mishamazor on Oct 31, '12 03:21:45AM

This works great, but is VERY slow. I assigned it to a folder action, so it runs automatically when photos are added to the "sub" folder, but it takes over Finder completely for a few minutes while running. Any suggestions??

Thanks,
Misha



[ Reply to This | # ]