This bash script can tidy up notes exported from Notion.
When exporting notes, Notion adds an identifier hash to the end of every filename and creates directories with exported images. This looks ugly when directly imported to Trilium.
Notion2Trilium strips the hashes off the filenames and directories (Renaming notes to their original form as they appeared in Notion).
As a consequence of renaming notes, links to images and other notes break during the process. However, Notion2Trilium loops through every note and fixes internal links.
- Export notes from Notion
- Unzip the exported file (e.g Export-xxxxxxxx-xxxx-xxxxx-xxxx-xxxxxxxxxxxx)
- Rename the exported folder to
Notion-Export
- Download
notion2trilium.sh
from this repo and place it next to theNotion-Export
folder - From a terminal run
chmod +x ./notion2trilium.sh
and./notion2trilium.sh
- Wait for the conversion process to finish. (Might take 5-10 minutes depending on the size of your Notion export)
- When the script if finished
zip
up theNotion-Export
folder. - Import the resulting
Notion-Export.zip
into Trilium
- The script performs two operations. First it renames every file by stripping hashes off the end of filenames. During this process, a hash database is built of all the identified files from the Export. This database is used for the 2nd operation where internal links are fixed within every note.
- The hierarchy of notes is saved, however the vertical order of notes are reset to an alphabetical order during conversion.
- Thank you Szymex for helping with the hash stripping