Export Enex file to be imported in Evernote from ColorNote db file colornote.db
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
<?php | |
# The file colornote.db is at this location: | |
# /data/data/com.socialnmobile.dictapps.notepad.color.note/databases/colornote.db | |
# this path is visible if your device is rooted and viewing as root with ES File Explorer for example | |
# see: | |
# https://nikiink.wordpress.com/2015/05/28/evernote-importing-from-lg-memo-and-from-colornote/ | |
# | |
$db = new SQLite3("colornote.db"); | |
$query = "SELECT * FROM notes"; | |
$result = $db->query($query); | |
$filename = "colornote.enex"; | |
$enexfile = fopen($filename, "w") or die("Unable to open output file!"); | |
fwrite($enexfile, '<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export3.dtd"> | |
<en-export application="Evernote" version="Evernote Win"> | |
'); | |
while ($row = $result->fetchArray(SQLITE3_ASSOC)) { | |
$created_date = $row['created_date']; | |
$modified_date = $row['modified_date']; | |
$created_date = substr($created_date, 0, strlen($created_date)-3); | |
$modified_date = substr($modified_date, 0, strlen($modified_date)-3); | |
$title = $row['title']; | |
$text = $row['note']; | |
echo "Exporting note: $title [" . date('d/m/Y', $created_date) . "]\n"; | |
// <created>20130730T205204Z</created> | |
// <updated>20130730T205624Z</updated> | |
fwrite($enexfile, | |
' <note> | |
<title>' . ($title?$title:'-untitled-') . '</title> | |
<content> | |
<![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"> | |
<en-note>' . nl2br($text) . '</en-note> | |
]]> | |
</content> | |
<created>' . date('Ymd', $created_date) . 'T' . date('His', $created_date). 'Z</created> | |
<updated>' . date('Ymd', $modified_date) . 'T' . date('His', $modified_date). 'Z</updated> | |
</note> | |
'); | |
} | |
fwrite($enexfile, '</en-export>'); | |
fclose($enexfile); | |
echo ">>>> EXPORT COMPLETED. OUTPUT FILE: $filename <<<<\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment