Photo by Team Nocoloco / Unsplash

印象笔记近乎完美的迁移至Notion

Tech 技术
/ 工具
2022年6月11日 ~

最近实在忍受不了印象笔记的臃肿和各种广告轰炸,虽然专业会员还有2年到期。

前段时间印象笔记团队推出了verse,号称是“面向未来的智能化生产力工具”,界面酷似notion,但广告依旧,立马没了兴趣。

替换前,尝试了Effie、Cubox、Notion、Workflowy等一系列产品,最终选择了Notion。原因很简单,我可以把印象笔记近乎完美的迁移至Notion。十分感谢vzhd1701,项目地址 => https://github.com/vzhd1701/enex2notion

我用的是 v0.2.14 版本,支持python 3.7、3.8、3.9和3.10,使用非常简单,操作命令见下:

$ enex2notion --help
usage: enex2notion [-h] [--token TOKEN] [OPTION ...] FILE/DIR [FILE/DIR ...]

Uploads ENEX files to Notion

positional arguments:
  FILE/DIR                   ENEX files or directories to upload

optional arguments:
  -h, --help                 show this help message and exit
  --token TOKEN              Notion token, stored in token_v2 cookie for notion.so [NEEDED FOR UPLOAD]
  --root-page NAME           root page name for the imported notebooks, it will be created if it does not exist (default: "Evernote ENEX Import")
  --mode {DB,PAGE}           upload each ENEX as database (DB) or page with children (PAGE) (default: DB)
  --mode-webclips {TXT,PDF}  convert web clips to text (TXT) or pdf (PDF) before upload (default: TXT)
  --add-pdf-preview          include preview image with PDF webclips for gallery view thumbnail (works only with --mode-webclips=PDF)
  --add-meta                 include metadata (created, tags, etc) in notes, makes sense only with PAGE mode
  --tag TAG                  add custom tag to uploaded notes
  --condense-lines           condense text lines together into paragraphs to avoid making block per line
  --condense-lines-sparse    like --condense-lines but leaves gaps between paragraphs
  --done-file FILE           file for uploaded notes hashes to resume interrupted upload
  --log FILE                 file to store program log
  --verbose                  output debug information
  --version                  show program's version number and exit

迁移步骤 👇🏻

第一步:安装 enex2notion,如果是mac电脑,用homebrew安装会非常容易,只需要执行 brew install vzhd1701/tap/enex2notion 即可。如果采用python安装,也很简单,执行 pip install enex2notion 即可;

第二步:拿到notion.com的token:打开chrome,输入https://notion.so,成功登陆,点击网址前的小锁,单击Cookie,点击www.notion.so,找到 token_v2,拷贝内容;

拿Token步骤1
拿Token步骤2
拿Token步骤3

第三步:从印象笔记导出,输出 .enex 文件;

第四步:通过命令行,导入到notion;

enex2notion --token [步骤2中拷贝的token_v2] --done-file clip-biz-done.txt  clip-biz.enex
注意:
一定要加 --done-file ,如果传输中遇到网络问题而中断,done file可以断点续传,如果没有,则会重新上传,出现两份,需手动删除。

小技巧

如何并行导入?

可以同时运行多个导入程序, 从而并行导入多个笔记本数据。

如何自动重试?

由于notion的服务器主要在美国,网络传输非常不稳定,经常需要重新执行,无法无人值守。推荐一个小工具 shell-retry,github地址:https://github.com/strizhechenko/shell-retry。可较好解决自动重新执行,但无法解决笔记格式错误问题。

安装方式:

pip install shell-retry

使用方式:

shell-retry --retry-count 30 --interval-max 30 --interval-min 5 -- enex2notion --token [步骤2中拷贝的token_v2] --done-file clip-biz-done.txt  clip-biz.enex
重试30次,最小重试间隔5秒,最大重试间隔30秒

完整使用方法:

$ shell-retry --help
usage: shell-retry [-h] [--backoff BACKOFF] [--retry-count RETRY_COUNT]
                   [--interval INTERVAL] [--verbose]
                   cmd [cmd ...]


positional arguments:
  cmd

optional arguments:
  -h, --help            show this help message and exit
  --backoff BACKOFF     backoff factor (sleep(--interval *= --backoff)
  --retry-count RETRY_COUNT
                        How many time re-run cmd if it fails
  --interval INTERVAL   Initial interval between retries
  --interval-max INTERVAL_MAX
                        upper limit for interval
  --interval-min INTERVAL_MIN
                        lower limit for interval
  --verbose             Be verbose, write how many retries left and how long
                        will we wait

小问题

近乎完美意味着还是有不尽人意的地方,列举几点:

  • 传输速度较慢:慢实际上并非网络问题,而是采用块传输,一个大断行即是一块。作者也知道该问题,最简单的方式是并行传输,但容易被notion限制,慢就慢吧,关键是能用就好;
  • 导入错误无法跳过而是停止:这个比较蛋痛,由于笔记结构问题,程序解析失败时会直接报错退出,这时候即使再运行依然会报错退出,只能手动把该笔记从印象笔记中去掉,再从印象笔记中导出 .enex 文件,再运行导入,只要 done-file 存在,还是可以断点续传。(已提交issue)

标签

JerryZ

大道至简,行者无疆!