# Exporting notes from app 'reminder'

The app 'reminders' (spanish name 'Notas') stores the notes in the directory \~/.local/share/com.ubuntu.reminders/@local as:

```
$ cat notes.cache
[notebooks]
4d853cee-9476-4e19-82fe-5f577b01698e=2

[notes]
a0ae2c53-1c7d-4d2a-b1c5-ea876e3f4ca1=10
da5e2110-d1a8-4470-a8bc-d5115720db57=21
efc58768-d28a-4df0-9e41-4893e5c2af54=2
```

deleted notes stay in the directory, like this one:

```
note-09f23799-df97-40f9-b4ff-6835688ed644.enml  (a deleted one)
```

they are just not referenced in the notes.cache file, like this one which is still valid:

```
note-efc58768-d28a-4df0-9e41-4893e5c2af54.enml  (a valid one)
```

for every note exist two files, a *.info file and the note itself in* .enml file:

```
$ ls -C1
note-09f23799-df97-40f9-b4ff-6835688ed644.enml
note-09f23799-df97-40f9-b4ff-6835688ed644.info
note-a0ae2c53-1c7d-4d2a-b1c5-ea876e3f4ca1.enml
note-a0ae2c53-1c7d-4d2a-b1c5-ea876e3f4ca1.info
notebook-4d853cee-9476-4e19-82fe-5f577b01698e.info
note-da5e2110-d1a8-4470-a8bc-d5115720db57.enml
note-da5e2110-d1a8-4470-a8bc-d5115720db57.info
note-efc58768-d28a-4df0-9e41-4893e5c2af54.enml
note-efc58768-d28a-4df0-9e41-4893e5c2af54.info
notes.cache
```

the \*.enml files contain the notes itself, HTML snipsets packed in XML, text is in UTF-8 encoded (enotacion format):

```markup
$ cat note-efc58768-d28a-4df0-9e41-4893e5c2af54.enml
<?xml version="1.0"?><!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note>
<p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; padding-left:0px; text-indent:0px;"><br/></p>
<p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; padding-left:0px; text-indent:0px;">9 de septiembre</p>
<p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; padding-left:0px; text-indent:0px;"><br/></p>
<ul><li>día de compras en la tienda de la Coop. Possidenti Oliveti Limone sul Garda, por unos 88 euro aceite del lugar, vino, etc.</li>
<li>gasolinera 43 euro, debe alcanzar la casa,</li>
<li>...<br/></li></ul></en-note>
```

as the titel of the note is stored in the \*.info file, it is a good idea to repeat the title in the note itself, for example if you have one note for any day, as I did showed it here with title "9 de septiembre";

With the help of Michael Zanetti <michael.zanetti@canonical.com> I got to work a small Qt5 application to parse the structure of the \*.info file:

<https://code.launchpad.net/~mzanetti/+junk/infodump>

```c
#include <QCoreApplication>
#include <QSettings>
#include <QDebug>
#include <QDateTime>
#include <QStringList>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    if (a.arguments().count() < 2) {
        qDebug() << "Error: No info file given";
        qDebug() << "usage:" << a.arguments().at(0) << "<infofile>";
        return 1;
    }
    qDebug() << "File:" << a.arguments().at(1);
    QSettings s(a.arguments().at(1), QSettings::IniFormat);
    qDebug() << "Title:" << s.value("title").toString();
    // qDebug() << "Tagline:" << s.value("tagline").toString().trimmed();
    qDebug() << "Created:" << s.value("created").toDateTime().toString("yyyy-MM-dd");
    qDebug() << "Updated:" << s.value("updated").toDateTime().toString("yyyy-MM-dd");
    // qDebug() << "Created:" << s.value("created").toString();
    // qDebug() << "Created:" << s.value("created").toDateTime().toMSecsSinceEpoch()/1000;
    return 0;
}
```

I compiled this in my chroot'ed env an use it together with a small shell script to export the files day by day:

```
#!/bin/sh

cd ~/.local/share/com.ubuntu.reminders/@local

foundnotes=0

while read line; do
  echo $line | fgrep -q '[notes]' && {
    foundnotes=1
    continue
  }
  if [ $foundnotes = 1 ]; then
    name=`echo $line | sed 's/=.*$//'`
    /home/phablet/myRoot/home/phablet/infodump/infodump note-$name.info > /tmp/info 2>&1
    title=`fgrep Title: /tmp/info | sed 's/Title: "//' | sed 's/"//g' | sed 's/ /-/g'`
    created=`fgrep Created: /tmp/info | sed 's/Created: "//' | sed 's/"//g'`
    updated=`fgrep Updated:  /tmp/info | sed 's/Updated: "//' | sed 's/"//g'`
    echo /tmp/${updated}:${title}.txt
    cat note-$name.enml > /tmp/${updated}:${title}.txt
  else
    continue
  fi
done < notes.cache

exit
```

The files end up in /tmp and can be fetched from there by SSH:

```
$ ls -l /tmp/*.txt
-rw-rw-r-- 1 phablet phablet 1122 sep 15 15:28 /tmp/2015-09-09:7-de-septiembre.txt
-rw-rw-r-- 1 phablet phablet  961 sep 15 15:28 /tmp/2015-09-09:8-de-septiembre.txt
-rw-rw-r-- 1 phablet phablet 1457 sep 15 15:28 /tmp/2015-09-09:9-de-septiembre.txt
-rw-rw-r-- 1 phablet phablet 2871 sep 15 15:28 /tmp/2015-09-11:10-de-septiembre.txt
-rw-rw-r-- 1 phablet phablet 1798 sep 15 15:28 /tmp/2015-09-11:11-de-septiembre.txt
-rw-rw-r-- 1 phablet phablet  980 sep 15 15:28 /tmp/2015-09-12:12-de-septiembre.txt
-rw-rw-r-- 1 phablet phablet  402 sep 15 15:28 /tmp/2015-09-15:13-de-septiembre.txt
```

Last updated: Wed Oct 28 20:05:11 CET 2015


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://guru-1.gitbook.io/bq-aquaris-e-4-5-ubuntu-phone/en/chapter31.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
