varsderk · 2022-01-24 16:48
Is there an easy way to move a ton of org files into org-roam? I've used just a flat directory of org files that I've searched with the excellent [Deft](https://github.com/jrblevin/deft) package for years, and I'd like to give org-roam a whirl. Is there an easy way to import all those notes in bulk? (Don't all notes need an ID?)
stuudente · 2022-01-24 18:15
Since v2 a basic unit of an org-roam data is called a node. You
can turn each file into a node by adding a property drawer at the
top. Following is a typical file I have under
`/path/to/org-roam/`.
:PROPERTIES:
:ID: 3f1330d9-6763-4dc8-b842-3f26facf9e4c
:END:
#+TITLE: 48 Laws of Power
+ author :: [[id:d646e109-763b-40ea-89be-6798c57bede1][Robert Greene]]
* Note
+ 01. Never outshine your master.
+ 10. Avoid the unhappy and unlucky
You are the average of the five people you spend most time with.
To make an org heading a node, add a property drawer immediately under it like this:
* Note
:PROPERTIES:
:ID: 00000000-6763-4dc8-0000-3f26facf9e4c
:END:
+ 01. Never outshine your master.
+ 10. Avoid the unhappy and unlucky
You are the average of the five people you spend most time with.
With this and db synced, `org-roam-node-find` prompts you a list of nodes, including `48 Laws of Power > Note`.
art_else · 2022-01-24 21:01
Be aware Deft doesn't work properly with org-roam as it uses the first line of the file as the title, so you get :property: etc. There is [some workaround](https://github.com/jrblevin/deft/issues/75) for it though.
varsderk · 2022-01-25 02:36
Ok, makes sense. Is there a utility to that *en masse*? I've got north of 200 files to convert.
stuudente · 2022-01-25 14:48
Not I am aware of. Do you have basic knowledge of elisp? I don't think it would be too hard to implement one.
Also, do your files have link references to each other?
varsderk · 2022-01-25 17:40
> elisp
Yes. I'm not a big-package-maintainer level wizard; I'm much more familiar with other dialects of Lisp. Building a few scripts would be a good thing to do to learn some more. It's just some time I don't quite have. (Maybe I should get off Reddit… nah. 🤪)
> link references
Some of them link to other files in the same directory. Maybe what I'll do is I'll start lazily converting my files as I need them from my old Deft repository.
stuudente · 2022-01-25 18:04
Backup your directory before running the scripts!
1. Write a script in any language that provides a property drawer for each file.
2. Write a script in any language that scans through each file: while encounter a link, grab the corresponding org-id, and make an org-link as in my example.
Hopefully it shouldn't be too hard...