├── README.md
└── enex-dump.php
/README.md:
--------------------------------------------------------------------------------
1 | enex-dump
2 | =========
3 |
4 | PHP script that accepts an Evernote export (ENEX) file and produces a folder of plain text documents.
5 |
6 | Please see comment at top of script for configuration and usage instructions.
7 |
8 | Note about non-breaking spaces
9 | ------------------------------
10 |
11 | I've found out the hard way that ENEX exports often contain non-breaking space characters (0xA0) that you may not notice right away because they look like regular spaces. This script does not remove them, so be aware that they might exist.
12 |
--------------------------------------------------------------------------------
/enex-dump.php:
--------------------------------------------------------------------------------
1 |
5 | //
6 | // This script takes an Evernote export (ENEX) file as input
7 | // and exports each individual note as a plain-text file in the
8 | // specified output folder.
9 | //
10 | // All HTML formatting and attachments are stripped out.
11 | //
12 | // The output files are named after the title of the note.
13 | //
14 | // The title of the note is also included as the first line of
15 | // the exported file.
16 | //
17 | // Script will attempt to create the output folder if it doesn't exist.
18 | //
19 | // Configure the variables below before running. Default paths are
20 | // relative to current directory.
21 | //
22 | // Invoke like so:
23 | //
24 | // php enex-dump.php
25 | //
26 | // By default, we look for an input file named "My Notes.enex",
27 | // but you can supply an additional parameter to override this:
28 | //
29 | // php enex-dump.php allnotes.enex
30 | //
31 |
32 | if ( $argc > 1 )
33 | {
34 | $file = $argv[1];
35 | }
36 | else
37 | {
38 | $file = "My Notes.enex"; // Path of default input file
39 | }
40 |
41 | $outdir = "output"; // Path of output folder
42 | $ext = "txt"; // Extension to use for exported notes
43 |
44 | //
45 |
46 | $pos = 0;
47 | $nodes = array();
48 |
49 | @mkdir($outdir);
50 |
51 | if ( !($fp = fopen($file, "r")) )
52 | {
53 | die("could not open XML input");
54 | }
55 |
56 | while ( $getline = fread($fp, 4096) )
57 | {
58 | $data = $data . $getline;
59 | }
60 |
61 | $count = 0;
62 | $pos = 0;
63 |
64 | while ( $node = getElementByName($data, "