(defun my-insert-file-content (filename)
(interactive)
(if (f-file-p filename)
(progn
(setq org-roam-capture-templates '(("d" "default" plain "%?"
:target (file+head "%(format-time-string \"%Y%m%d%M%H%S\")-%(file-name-base filename).org" "#+title: %(file-name-base filename) \n %(f-read-text filename) \n ") :unnarrowed t)))
(org-roam-capture)
)))
(advice-add 'org-roam-capture :after 'org-capture-finalize)
(cl-defun org-roam-capture (&optional goto keys &key filter-fn templates info)
"Launches an `org-capture' process for a new or existing node.
This uses the templates defined at `org-roam-capture-templates'.
Arguments GOTO and KEYS see `org-capture'.
FILTER-FN is a function to filter out nodes: it takes an `org-roam-node',
and when nil is returned the node will be filtered out.
The TEMPLATES, if provided, override the list of capture templates (see
`org-roam-capture-'.)
The INFO, if provided, is passed along to the underlying `org-roam-capture-'."
(interactive "P")
(let ((node (org-roam-node-create)))
(org-roam-capture- :goto goto
:info info
:keys keys
:templates templates
:node node
:props '(:immediate-finish nil))))
;; 替换成你自己的目录
(mapc 'my-insert-file-content (directory-files "~/Github/my-notes/pages/" t))
最近用了一段时间 logseq ,感觉还是没有在Emacs下面用org roam 爽,还是决定切到 org roam,写了一小段脚本可以用来批量迁移, 不过对于tags迁移不到位,目前是按照文件名来新建Node的。