Import from Notion

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