-
-
Save nanoant/d97b7b0b4f23b1a9b6e85707b1be1d78 to your computer and use it in GitHub Desktop.
Download .icloud files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See: https://apple.stackexchange.com/questions/328329/is-there-a-way-via-the-command-line-to-cause-icloud-files-to-download | |
import Foundation | |
func main() { | |
let fm = FileManager.default | |
for path in CommandLine.arguments[1...] { | |
let url = NSURL.fileURL(withPath: path) | |
guard fm.fileExists(atPath: url.path) else { | |
fputs("\(url.path): doesn't exist\n", stderr) | |
continue | |
} | |
do { | |
try fm.startDownloadingUbiquitousItem(at: url) | |
} catch { | |
fputs("\(url.path): \(error.localizedDescription)\n", stderr) | |
} | |
} | |
} | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
func main() { | |
let fm = FileManager.default | |
for path in CommandLine.arguments[1...] { | |
let url = NSURL.fileURL(withPath: path) | |
guard fm.fileExists(atPath: url.path) else { | |
fputs("\(url.path): doesn't exist\n", stderr) | |
continue | |
} | |
do { | |
try fm.evictUbiquitousItem(at: url) | |
} catch { | |
fputs("\(url.path): \(error.localizedDescription)\n", stderr) | |
} | |
} | |
} | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment