This script will convert notes from Synology Note Station to plain-text markdown notes.
The script is written in Python and should work on any desktop platform. It's tested on Linux, Windows 7, mac OS 10.15.
After conversion you will 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 text;
- All images and attached files in
media
sub-directories inside notebook directories.
- The script requires Python 3.5+ and pandoc installed on your system. Get the install package or use the package manager of your OS.
- Put
nsx2md.py
to the directory, where you want to convert notes. - (Linux only, optional) Give
nsx2md.py
"execute" permission.
- Export your Synology Note Station notebooks by: Setting -> Import and Export -> Export. You will get .nsx file.
- Adjust the .nsx file permission if required. Mine was readable only by owner user.
- Copy the .nsx file(s) to the directory where you've put
nsx2md.py
. - Set option settings if required - see the "Optional settings" section below.
- Run
nsx2md.py
orpython nsx2md.py
to convert all the .nsx files in the directory. It won't delete them.
... or run nsx2md.py path/to/export.nsx
to convert a specific file. Converted notes will appear where the file is.
nsx2md.py
can be located anywhere as long as you specify the file you want to convert.
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 meta data options:
meta_data_in_yaml
- True
YAML block the following meta data that are set True, False
meta data 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:
links_as_URI
- True
for file://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.