This script converts notes from Synology Note Station to plain-text markdown notes.
The script is written in Python and should work on any desktop platform.
After conversion you get:
- Directories named like the exported notebooks;
- Notes in those directories as markdown-syntax plain text files with all in-line images in-place;
- Assigned tags and links to attachments at the beginning of note texts;
- All images and attached files in
media
subdirectories inside notebook directories.
- The script requires Python 3.5+ and pandoc installed on your system. Get the installation packages or use the package manager of your OS.
- Put
nsx2md.py
to the directory, where you want to convert notes.
- Export your Synology Note Station notebooks by: Setting -> Import and Export -> Export. You will get .nsx file.
- Adjust the .nsx file permissions if required.
- Copy the .nsx file(s) to the directory where you've put
nsx2md.py
. - Set script settings if required - see the "Optional settings" section below.
- Run
python nsx2md.py
to convert all the .nsx files in the directory orpython nsx2md.py path/to/export.nsx
to convert a specific file.
build Docker image
docker build -t nsx2md .
run the docker image
docker run -it -v "$PWD:/nsx2md nsx2md <file.nsx>
Inside the script you can make some adjustments to the link format and notes metadata:
Select metadata options:
meta_data_in_yaml
- True
YAML block the following metadata that are set True, False
metadata will be in text;
insert_title
- True
to insert note title as a markdown heading at the first line, False
to disable;
insert_ctime
- True
to insert note creation time to the beginning of the note text, False
to disable;
insert_mtime
- True
to insert note modification time to the beginning of the note text, False
to disable;
tags
- True
to insert list of tags, False
to disable;
tag_prepend
- string to prepend each tag in a tag list inside the note, default is empty;
tag_delimiter
- string to delimit tags, default is comma separated list;
no_spaces_in_tags
- True
to replace spaces in tag names with '_', False
to keep spaces.
Select file link options:
prepend_links_with
- Prepends file links with set string (ex. 'file://'
), ''
for no prepend
encode_links_as_uri
- Encodes links' special characters with "percent-encoding, True
for /link%20target
style links, False
for /link target
style links
absolute_links
- True
for absolute links, False
for relative links;
Select File/Attachments/Media options:
media_dir_name
- name of the directory inside the produced directory where all images and attachments will be stored;
md_file_ext
- extension for produced markdown syntax note files;
creation_date_in_filename
- True
to insert note creation time to the note file name, False
to disable;
For QOwnNotes users
There are several ways to get tags from converted notes to work in QOwnNotes:
- Convert .nsx files with default
nsx2md.py
settings; - Add notebook directories produced by
nsx2md.py
as QOwnNotes note folders; - Set one of these note folders as current;
- Enable provided
import_tags.qml
script in QOwnNotes (Note -> Settings -> Scripting) (remove_tag_line.py
should be at the same directory); - The script will add 2 new buttons and menu items:
1. Import tags
- to import tags from the tag lines of all the notes in the current note folder
2. Remove tag lines
- to remove the tag lines from all the notes in the current folder - Use the buttons in the according order, any previous QOwnNotes tag data for the note folder will be lost;
- Move to the next note folder produced by
nsx2md.py
, repeat #5; - Disable
import_tags.qml
script. That is obligatory.
- For default
@
tag prepends use the followingnsx2md.py
settings:
tag_prepend = '@' # string to prepend each tag in a tag list inside the note, default is empty
tag_delimiter = ' ' # string to delimit tags, default is comma separated list
no_spaces_in_tags = True # True to replace spaces in tag names with '_', False to keep spaces
- Convert .nsx files;
- Add notebook directories produced by
nsx2md.py
as QOwnNotes note folders.