Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Export Enex file to be imported in Evernote from LG Memo db file richnote
# 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:
$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 "">
<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>
<![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE en-note SYSTEM "">
<en-note>' . nl2br($text) . '</en-note>
<created>' . date('Ymd', $created_date) . 'T' . date('His', $created_date). 'Z</created>
fwrite($enexfile, '</en-export>');
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