Last active
May 31, 2020 20:36
-
-
Save philipmw/2cd92d4a21b33c9394092db2dbb428a3 to your computer and use it in GitHub Desktop.
convert fruux tasks ICS into plain text
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
#!/bin/sh -x | |
########### | |
# Problem this solves: | |
# | |
# I use Fruux (fruux.com) as the backend to my iOS Reminders app. Rather than for actual | |
# reminders, I used it for general notes, roughly one Reminders entry to a paragraph of notes. | |
# Later I decided to switch to using the actual iOS Notes app, with my email provider | |
# (fastmail.fm) as the backend. | |
# | |
# But how to transfer my existing data? Fruux lets me download each set of Reminders | |
# (they call it Tasks) as an .ics file. This little shell script takes this .ics file | |
# as its input and outputs my content as plain text. The only remaining problem is that | |
# the content is out of order. I suspect it uses timestamps in the file to know how to | |
# order it on the device. So I convert to plaintext using this script, then reorder | |
# manually in a text editor by looking at the original content on Fruux web interface, | |
# then finally paste the plaintext into my new notes backend. | |
# | |
# How to use: | |
# | |
# 1. Download the .ics file from Fruux | |
# 2. cat {ics-file} | ./this-script.sh > plaintext.txt | |
# | |
########### | |
########### | |
# Each command in the pipeline documented, since I cannot put inline comments: | |
# | |
# 1. `awk`: Text content we care about is only in the SUMMARY field, so take only lines | |
# between SUMMARY: and the next field, UID:. | |
# 2. `grep -v`: But we don't actually want the UID field, so exclude those lines. | |
# 3. `sed`: Replace SUMMARY prefix with a paragraph linebreak. Now each entry of the | |
# original file is its own paragraph, separated by an empty line, with the first line of | |
# each paragraph starting at the first column and all subsequent lines starting with a | |
# single space. | |
# 4. `sed`: Join all lines within each paragraph. Now each paragraph is on a single line. | |
# 5. `sed`: Commas and semicolons are backslash-escaped, so remove the escaping. | |
# | |
########### | |
awk '/SUMMARY:/, /UID:/ { print $0 }' \ | |
| grep -v UID \ | |
| sed "s/SUMMARY:/\\"$'\r'"\\"$'\n'"/" \ | |
| sed -E -e ':a' -e '$!N' -e "s/"$'\r'$'\\n'" //" -e 't a' -e 'P' -e 'D' \ | |
| sed 's/\\\([;,]\)/\1/g' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment