Last active
May 8, 2019 14:35
-
-
Save alexito4/f921aebdadb90b78b44831ef103ab370 to your computer and use it in GitHub Desktop.
Swift script to convert Reminders export files (.ics) to lists.
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
#!/usr/bin/swift sh | |
import Foundation | |
guard let path = CommandLine.arguments.dropFirst().first else { exit(1) } | |
print(path) | |
let content = try! String(contentsOfFile: path) | |
let lines = content | |
.split(separator: "\r\n") | |
let summaryPrefix = "SUMMARY:" | |
let extraPrefix = "X-APPLE-ACTIVITY;VALUE=" | |
var items = [String]() | |
for line in lines { | |
if line.starts(with: summaryPrefix) { | |
items.append(String(line.dropFirst(summaryPrefix.count))) | |
} | |
if line.starts(with: extraPrefix) { | |
items[items.count-1].append(" \(line.dropFirst(extraPrefix.count))") | |
} | |
} | |
print("Found \(items.count) items.") | |
print(items.joined(separator: "\n")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment