I've been playing around with AppleScript and iCloud Drive, with the ultimate goal of writing a script to back up the contents of my iCloud Drive to a local external hard drive every night. I've already learned the hard way that it is easy to delete a file on iCloud Drive by accident, and that the deletion propagates automatically and immediately to all local devices -- local backup is a good plan, I believe.
Here is a sample script that displays my initial discoveries. Can anybody point me to documentation or discussion of this topic? I've already found discussion of iCloud Documents & Data in Mavericks, but I'm specifically interested in iCloud Drive in Yosemite. If anybody else is looking into this, do you have discoveries to share?
--iCloud Drive Test Script
--Bill Cheeseman 2014-10-22
-- Select iCloud Drive in a Finder window's sidebar and create a folder named "Documents" in it before running this script. Uncomment any line and run the script to test that line.
property userName : "cheeseb" -- change this to your user name
-- TEST ICLOUD DRIVE WINDOW:
tell application "Finder"
tell window 1
-- return name --> "iCloud Drive" -- name of the Finder window when iCloud Drive is selected in the sidebar
-- return every item --> {folder "Documents" of folder "com~apple~CloudDocs" of folder "Mobile Documents" of folder "Library" of folder "cheeseb" of folder "Users" of startup disk of application "Finder"} -- AppleScript can see user-created folders in iCloud Drive, but it can't see the application-created folders when accessing folder "com~apple~CloudDocs"
end tell
end tell
-- TEST ICLOUD DRIVE'S "com~apple~CloudDocs" FOLDER:
tell application "Finder"
tell folder "Library" of folder userName of folder "Users" of startup disk of application "Finder"
-- return every item of folder "com~apple~CloudDocs" of folder "Mobile Documents" --> {folder "Documents" of folder "com~apple~CloudDocs" of folder "Mobile Documents" of folder "Library" of folder "cheeseb" of folder "Users" of startup disk of application "Finder"} -- these are iCloud Drive's user-created folders, such as "Documents"
-- return every item of folder "Documents" of folder "com~apple~CloudDocs" of folder "Mobile Documents" --> {document file "Backup and Sync Application Notes.rtf" of folder "Documents" of folder "com~apple~CloudDocs" of folder "Mobile Documents" of folder "Library" of folder "cheeseb" of folder "Users" of startup disk of application "Finder", ...} -- these are the contents of the user-created "Documents" folder
end tell
end tell
-- TEST ICLOUD DRIVE'S "Mobile Documents" FOLDER
tell application "Finder"
tell folder "Library" of folder userName of folder "Users" of startup disk of application "Finder"
-- return name of every item of folder "Mobile Documents" --> {folder "243LU875E5~com~apple~movietrailers" of folder "Mobile Documents" of folder "Library" of folder "cheeseb" of folder "Users" of startup disk of application "Finder", ...} -- these appear to be OS X and iOS application-created folders in iCloud Drive, plus the "com~apple~CloudDocs" folder tested above.
tell item 1 of folder "Mobile Documents"
-- return name --> "243LU875E5~com~apple~movietrailers"
-- return displayed name --> "iTunes Trailers" -- this is the user-readable name of the data folder for the iTunes Trailers iOS app from Apple
end tell
end tell
end tell
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives:
http://lists.apple.com/archives/applescript-users
This email sent to email@hidden