Convert ColorNote Notes to Nextcloud Notes

Sadly the android app "ColorNote" does not support any export.

I'm currently converting as much as I can to free software. Therefore I wanted to switch from ColorNote to Nextcloud Notes app. I found this article which helped a lot: https://haukerehfeld.de/notes/2017-02-colornote-export/

I'm using Ubuntu Linux 16.04. First I created an adb backup and extracted it as described in the link above.

Furthermore I installed and activated the "Notes" app in Nextcloud.

DB extract & Conversion

  • mkdir -p ~/colornote_migration/notes
  • cd ~/colornote_migration
  • adb backup -noapk com.socialnmobile.dictapps.notepad.color.note
    • You need android adb installed on your system
  • java -jar /home/klemens/bin/android-backup-tookit/android-backup-extractor/android-backup-extractor-20180521-bin/abe.jar unpack backup.ab backup.tar
  • tar -xvf backup.tar
  • sudo apt get install sqlitebrowser
  • Launch sqlitebrowser
    • Open "apps/com.socialnmobile.dictapps.notepad.color.note/db/colornote.db" (sqlite db)
    • SELECT datetime(created_date/1000,'unixepoch') as created, datetime(modified_date/1000,'unixepoch') as modified,title,note FROM notes ORDER BY created
    • Export as csv to colornote.csv
  • I wrote a little php script which converts the csv to separate text files. See the zip archive below.
  • vi convert.php
    • <?php
      
      $dir = "notes";
      
      //$row = 1;
      if (($handle = fopen("colornote.csv", "r")) !== FALSE) {
          while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
            /*
              [0] =>
              string(19) "2019-05-09 16:44:08"
              [1] =>
              string(19) "2019-05-09 16:44:27"
              [2] =>
              string(xx) "title"
              [3] =>
              string(xx) "complete note text"
            */
            
             // remove illegal chars
             $filename = preg_replace("/[^A-Za-z0-9 _äöüÄÖÜß.-]/", '_', $data[2]);
             $path = $dir . '/' . $filename . '.txt';
             
             file_put_contents($path, $data[3]);
      
             // fix times
             touch($path, strtotime($data[1]));
      
          }
          fclose($handle);
      }
  • php convert.php
  • The separate .txt files should now be in subdir "notes"
  • Select all files and copy them into the subdir "Notes/" of your nextcloud home dir
  • Done, the notes are even sorted by modify date!