ICloud – way via the command line to cause .icloud files to download

command lineicloudterminal

Under iCloud in the Settings app, I have "Optimize Mac Storage" checked and "Desktop & Documents Folders" checked under "Apps that store documents and data in iCloud will appear here:"

enter image description here

This will cause some files in my "Documents" folder to be offloaded and replaced with a small file ending in ".icloud". I can download them by clicking on the cloud icon in the detail view in the Finder. I can also use "find" from the command line to show which files have been offloaded, eg "find . -name *.icloud | more".

Is there a command line way to cause these files to be downloaded, either by file or directory?

Best Answer

Scott Garret and Allan’s answer above is very close.

In the terminal, however, each *.icloud file is prefixed with a . when NOT downloaded.

For example, a directory called foo with optimised (i.e., offloaded to icloud) files a.txt and b.txt will look like this

$ cd foo
$ find . -name '.*icloud’
./.a.txt.icloud
./.b.txt.icloud

To resolve (i.e., download) the files from icloud, you need to pass the path to the resulting path to /usr/bin/brctl.

Thus, the following works.

find . -name '.*icloud' | perl -pe 's|(.*)/.(.*).icloud|$1/$2|s' | while read file; do brctl download "$file"; done

You can monitor the download activity as per this answer as follows :

brctl log --wait --shorten