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.']

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...

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 :-)

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.

"[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

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?

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.

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.

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.

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.

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:

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.

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.

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.

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.

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

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.

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.

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

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??