Skip to content

Instantly share code, notes, and snippets.

@nanoant
Forked from anongit/icget.swift
Created August 13, 2019 17:50
Show Gist options
  • Save nanoant/d97b7b0b4f23b1a9b6e85707b1be1d78 to your computer and use it in GitHub Desktop.
Save nanoant/d97b7b0b4f23b1a9b6e85707b1be1d78 to your computer and use it in GitHub Desktop.
Download .icloud files
// 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()
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