Import / Migration

This is a best effort list on how to import your tasks from other task managers to TaskLite.



YAML File

If you have all you tasks in one YAML file like this:

- id: 123
  body: Buy milk
  tags: [groceries]

- id: 456
  body: Go running
  tags: [sport]

Run following command to import it. Be sure to make yaml2json available in your path and to install jq first.

cat tasks.yaml \
| yaml2json \
| jq -c '.[]' \
| while read -r task
  do
    echo "$task" | tasklite importjson
  done

Taskwarrior

TaskLite supports all fields of Taskwarrior's export format. Therefore migration is really simple:

task export rc.json.array=off \
| while read -r task; \
  do echo $task | tasklite importjson; \
  done

Google Tasks

There is currently no proper way to export tasks.

A workaround is:

  1. Open the standalone view of Google Tasks
  2. Select all text with cmd + a and copy it
  3. Paste it in a text editor
  4. Format it properly
  5. Import it with a while loop as seen in the Taskwarrior section

Google Keep

You can export all tasks / notes from Google Keep via Google Takeout. It provides a Takeout/Keep directory with one .html and .json file per task.

To import the .json files, change into the directory and run following command:

find . -iname '*.json' \
| while read -r task
  do
    jq -c \
      '.textContent as $txt
        | .labels as $lbls
        | .title as $title
        | (if .isArchived then "done"
          elif .isTrashed then "deletable"
          else null
          end) as $state
        | {
            utc: .userEditedTimestampUsec,
            body: ((if $title and $title != "" then $title else $txt end)
              + (if .listContent
                then "\n\n" +
                  (
                    .listContent
                    | map("- [" + (if .isChecked then "x" else " " end) + "] "
                      + .text)
                    | join("\n")
                  )
                else ""
                end))

          }
        | if $lbls then . + {tags: ($lbls | map(.name))} else . end
        | if $title and $title != "" and $txt and $txt != ""
          then . + {notes: [{body: $txt}]}
          else .
          end
        | if $state then . + {state: $state} else . end
      ' \
      "$task" \
    | tl importjson
  done

The title of the Google Keep note becomes the body of the task and the note itself becomes a TaskLite note attached to the task. A list of sub-tasks will be converted to a GitHub Flavored Markdown task list.

Telegram

Telegram's "Saved Messages" -- a.k.a. messages to oneself -- are a pretty convenient inbox. Here is how to move them to TaskLite afterwards:

  1. Install Telegram Desktop brew install telegram-desktop

  2. Go to "Saved Messages"

  3. Click on 3 dots in the upper right corner

  4. Click on "Export chat history"

  5. Deselect all additional media and select "JSON" as output format

  6. Approve download on a mobile device

  7. Download the JSON file (if download window was closed, simply follow the previous steps again)

  8. Either import it directly as JSON or convert it first to YAML for cleanup.

    Import JSON directly:

    cat result.json \
    | jq -c '
      .messages
        | map(
            (if (.text | type) == "string"
            then .text
            else (.text
                | map(
                    if (. | type) == "string"
                    then .
                    else .text end
                  )
                | join(", ")
              )
            end) as $body
            | {
              utc: .date,
              body: $body,
              tags: ["telegram"]
            }
          )
        | .[]
      ' \
    | while read -r task
      do
        echo "$task" | tasklite importjson
      done
    

    Convert it to YAML for easier cleanup:

    jq '.messages' result.json | yq --yaml-output > out.yaml
    
  9. Clear chat history on Telegram

Apple Reminders

Use following Apple Script to display the reminders including their creation timestamp. Seen at discussions.apple.com/thread/8570915.

  1. Download the script: export-reminders.scpt
  2. Run it with:
    osascript export-reminders.scpt
    
  3. Enter the name of the list you want to export

    ⚠️ Warning
    It includes all reminders - even completed ones - in the list. If it's a long list, it will take a while. A better approach would be to create a new list and move all reminders you want to export to that list.

  4. Copy and paste the output into a tasks.json file
  5. Format it as proper JSON and manually add notes, and tags fields
  6. Import JSON file:
    cat tasks.json \
      | jq -c '.[]' \
      | while read -r task
        do
          echo $task | tasklite importjson
        done
    

Fixing Mistakes

It's easy to write a short shell script to fix any mistakes you might have made during the import process.

In following example I forgot to use the metadata field end to set the closed_utc column, but used the current date instead.

As I deleted all metadata afterwards, I now need to extract the field from an old backup. In the meantime I changed some closed_utc fields and therefore I can't fully automate it. A neat little trick I came up with is to automatically paste the correct value into the clipboard, so I only have to insert it at the right location.

A fish script to fix the mistake could look like this:

sqlite3 \
  ~/TaskLite/main.db \
  "SELECT ulid FROM tasks WHERE closed_utc LIKE '%2024-02-26%'" \
| while read ulid \
    ; echo "$ulid" \
    ; and \
      sqlite3 \
        ~/TaskLite/backups/2024-02-14t1949.db \
        "SELECT json_extract(metadata, '\$.end') FROM tasks WHERE ulid == '$ulid'" \
      | tee /dev/tty \
      | pbcopy \
    ; and tl edit "$ulid" \
  ; end