Import from Notion

Hi everyone, just wanted to share this importer I made. You just need to export your Notion notes, unzip the file, and then run this script using Node.

GitHub Link

There is a little documentation on the GitHub README but I was encouraged to share this point in particular:
Warning: Notion pages that contain parentheses or dashes in the title will have them removed by Notion while exporting your data so the file will be created without them, even though the link itself will still retain them.

7 Likes

Thanks for creating this! Looks good!
I’m excited to try it.


I tested it on macOS Mojave with node 10.13
First try:
Ran node main and when it asked for Notion Export path I dragged the folder over the terminal window (works with most command line utils in macOS).

Got this error:
readline.js:1032
throw err;
^

Error: ENOENT: no such file or directory, scandir '/Users/rsdimitrov/Downloads/Export-b7bea5ff-da8c-48e2-864e-3ee93310425f '

Second try:
Fixed the above error by manually trimming the extra whitespace at the end of the path.
Then got this error
readline.js:1032
throw err;
^

Error: ENOENT: no such file or directory, rename '/Users/rsdimitrov/Downloads/Export-b7bea5ff-da8c-48e2-864e-3ee93310425f\.DS_Store' -> '.DS_Store'
at Object.renameSync (fs.js:591:3)
at fixNotionExport (/Users/rsdimitrov/Downloads/Notion-to-Obsidian-Converter-master/main.js:153:7)
at rl.question (/Users/rsdimitrov/Downloads/Notion-to-Obsidian-Converter-master/main.js:10:17)
at Interface._onLine (readline.js:288:5)
at Interface._line (readline.js:638:8)
at Interface._ttyWrite (readline.js:919:14)
at ReadStream.onkeypress (readline.js:168:10)
at ReadStream.emit (events.js:182:13)
at emitKeys (internal/readline.js:424:14)
at emitKeys.next (<anonymous>)

Third try:
Deleted .DS_Store folder from the root path
Then got this:

readline.js:1032
        throw err;
        ^

Error: ENOENT: no such file or directory, rename '/Users/rsdimitrov/Downloads/Export-b7bea5ff-da8c-48e2-864e-3ee93310425f\Inbox aa646ee03f274e3c8053c8ae3f794295.md' -> '/Users/rsdimitrov/Downloads/Export-b7bea5ff-da8c-48e2-864e-3ee93310425f\Inbox.md'
    at Object.renameSync (fs.js:591:3)
    at fixNotionExport (/Users/rsdimitrov/Downloads/Notion-to-Obsidian-Converter-master/main.js:153:7)
    at rl.question (/Users/rsdimitrov/Downloads/Notion-to-Obsidian-Converter-master/main.js:10:17)
    at Interface._onLine (readline.js:288:5)
    at Interface._line (readline.js:638:8)
    at Interface._ttyWrite (readline.js:919:14)
    at ReadStream.onkeypress (readline.js:168:10)
    at ReadStream.emit (events.js:182:13)
    at emitKeys (internal/readline.js:424:14)
    at emitKeys.next (<anonymous>)

Judging by the errors your script assumes I’m not on an unix-based system and my filesystem uses backslashes \ instead of forwardslashes /

Suggestions

Make it accept command line parameters instead of asking for the path once the script is run. This way I can use the autocomplete function of the bash/terminal and construct the correct path easier.

Also, I think this article will help: https://shapeshed.com/writing-cross-platform-node/

Edit: Fixed it to run without errors on macOS by changing line 144 from
var currentPath = path + '\\' + currentDirectory[i].name;
to
var currentPath = path + '\/' + currentDirectory[i].name;

3 Likes

Hi, @rsdimitrov, thank you for finding that issue. I had to make a previous change because a user found it wasn’t working on Ubuntu. I’m sorry I’m just now seeing this; I don’t get on the forum frequently and I only get notifications for GitHub issues. I’ll make this an issue and get around to fixing it as soon as I get the free time.

Thank you for trying it out and letting me know the issues you came across!

1 Like

Thanks. I got it to work under Linux. For others, if you want to run javascript from the terminal, your need to install nodejs first. Install command:
sudo apt install nodejs

I made a hacky fix, node supports paths on most OSes with path.sep. I made a pull request to your repo here :slight_smile:
https://github.com/connertennery/Notion-to-Obsidian-Converter/pull/9

1 Like

tnx! works awesome without errors. win10

1 Like