evernote2md

repository·master·Indexed 22 days ago

https://github.com/wormi4ok/evernote2md

A CLI tool designed to convert Evernote exports (.enex files) into organized Markdown files. It supports attachments, tags, and metadata, preserving links to media resources and setting file dates based on note attributes. The tool can be installed via Homebrew, as a pre-compiled binary, or run using Docker.

Tokens
1.7K
Snippets
7
Records
8
Agent score
76%

What's inside evernote2md

  1. Use evernote2md via CLI

    master

    The evernote2md CLI tool converts Evernote .enex files into a directory of Markdown files. It handles attachments by creating image and file directories and preserves links to them. It also converts Evernote tags into text entries and sets file dates based on note attributes.

    Basic Syntax

    evernote2md (flags) [input] [outputDir]

    Arguments

    • input: A single .enex file, a directory containing exported files, or a glob pattern (e.g., exports/My*.enex or exports/**/*.enex).
    • outputDir: The destination directory for Markdown files. If omitted, the tool defaults to ./notes.

    Key Options

    • --tagTemplate: Allows you to customize how Evernote tags are formatted within the notes. See the Custom tag template wiki for details.
    • --help: Displays all available options.

    Example

    If you have an export file named my_notes.enex and want to export to a folder named my_markdown_notes:

    evernote2md my_notes.enex my_markdown_notes
  2. Use the evernote2md CLI to convert Evernote notes

    master

    The evernote2md CLI tool converts Evernote notes exported in *.enex format into a directory of Markdown files. You can provide a specific file, a directory, or a glob pattern as input. By default, output is placed in a ./notes directory.

    # Convert a single enex file
    evernote2md my_notes.enex
    
    # Convert all enex files in a directory to a specific output folder
    evernote2md ./my_export_folder -o ./markdown_output
    
    # Use glob patterns
    evernote2md "./exports/*.enex"
  3. Run evernote2md with Docker

    master

    You can run the tool using a Docker container. You must mount your current working directory to /tmp inside the container to allow the tool to access your .enex files and write the output.

    docker run -t --rm -v "$PWD":/tmp -w /tmp wormi4ok/evernote2md:latest (flags) [input] [outputDir]
  4. Save notes to a directory using noteFilesDir

    master

    The noteFilesDir type manages saving Evernote notes as Markdown files and their associated media resources to a specific filesystem directory.

    Configuration

    You initialize a noteFilesDir using newNoteFilesDir(output string, folders bool, timestamps bool).

    • output: The base directory where notes will be saved.
    • folders: If true, each note is saved into its own subfolder named after the note, with the content file named README.md. If false, notes are saved as individual .md files directly in the output directory.
    • timestamps: If true, the filesystem creation and modification times of the saved files will be updated to match the note's CTime and MTime.

    Saving a Note

    Use the SaveNote(title string, md *markdown.Note) error method to write a note to disk. This method automatically handles:

    1. Generating a unique filename to prevent collisions.
    2. Saving the Markdown content.
    3. Updating file timestamps (if enabled).
    4. Saving all media attachments (images, etc.) into subdirectories named after their resource type within the note's path.
    // Example initialization and usage
    d := newNoteFilesDir("./output", true, true)
    
    err := d.SaveNote("My Travel Note", myMarkdownNote)
    if err != nil {
    	log.Fatal(err)
    }
  5. Reference the evernote2md CLI flags and arguments

    master

    The following table lists the available positional arguments and flags for the evernote2md command-line interface.

    ### Positional Arguments
    | Argument | Description |
    | --- | --- |
    | `<input>` | Evernote export file, directory or a glob pattern |
    | `<output>` | Output directory (positional, though `-o` is preferred) |
    
    ### Flags
    | Flag | Short | Description |
    | --- | --- | --- |
    | `--tagTemplate` | `-t` | Define how Evernote tags are formatted |
    | `--outputDir` | `-o` | Override the directory where markdown files will be created |
    | `--folders` | | Put every note in a separate folder |
    | `--noHighlights` | | Disable converting Evernote highlights to inline HTML tags |
    | `--escape-special-chars` | | Escape special characters to ensure correct rendering of the converted files |
    | `--resetTimestamps` | | Create files ignoring timestamps in the note attributes |
    | `--addFrontMatter` | | Prepend FrontMatter to markdown files |
    | `--debug` | `-v` | Show debug output |