Last active
August 29, 2015 14:22
-
-
Save nikiink/d94c5e2d3d964740a34c to your computer and use it in GitHub Desktop.
Export Enex file to be imported in Evernote from LG Memo db file richnote
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 lg memo db file richnote is at this location: | |
# /storage/sdcard0/Memo/backup.nrt | |
# this file is created after making a backup and this is a zip file, | |
# the file richnote is inside the zip | |
# see: | |
# https://nikiink.wordpress.com/2015/05/28/evernote-importing-from-lg-memo-and-from-colornote/ | |
# | |
$db = new SQLite3("richnote"); | |
$query = "SELECT * FROM notes"; | |
$result = $db->query($query); | |
$filename = "lgmemo.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['time']; | |
$created_date = substr($created_date, 0, strlen($created_date)-3); | |
$title = $row['title']; | |
$text = $row['textonly']; | |
echo "Exporting note: $title [" . date('d/m/Y', $created_date) . "]\n"; | |
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> | |
</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