So perfectly possible that I’m missing something but yeah, let. me explain a bit more
The specific workflow I want to focus on is doing a one-way merge from the database I’m building up at my new job to my personal one. During the work day I mostly take notes on my work computer. As I’ve been onboarding, it has quickly ballooned to >100 heavily interlinked entries as I’m really using it to capture knowledge constantly coming at me in meetings.
Much of it I do want in my personal roam notes but I
- Can’t have Dropbox installed on that machine (not approved for our environment)
- I don’t actually want any of my personal non-work-related notes on my work machine as they could technically claim ownership of these (call this an overabundance of caution, not any sort of problem with my employer - they’re cool)
- I already have a sizable database which I cannot recreate easily
So while I don’t need notes on - for example - who our HR director is in my personal roam; I do want notes about more general things I’m learning about (such as Google Cloud, Hi-Trust Compliance, etc) there. Additionally, deciding which database I need to put a note into at the time of creating a note and switching between computers is simply too much of a workflow interruption when I’m already working as fast as I can to keep up at meetings.
So what I would like, is to do a weekly one-way merge from my work to my personal notes. Probably with an “ignore” list for notes that I don’t want to bring over as they contain info that should best remain only in the work database.
Moving the files over is easy, the hard part is when I have the same note in both databases. So for example I have a Google Cloud Platform
note in both with some knowledge in my personal, and a lot more in my work one as I’ve been getting familiar with it on company time. The content of these should really be merged.
It’s even tougher when you consider outgoing links. So for example in my personal roam, outgoing links to the Python
note look like this: [[file:20200529235210-python.org][Python]]
.Bbut of course in my work one that would be different. It’s called Python
in both, but they were created at different times and so the timestamp portion of the filename is not the same! This needs to be resolved for the note graph to remain intact. This is also why a simple script like the one @kimmy posted (thanks by the way!) is not going to work for me.
So I’m thinking this will have to be written in elisp (well it doesn’t have to, but I have roam utility functions already available there). I’m thinking something like the following:
* The Plan
** Open a logging window
** Iterate through all the files in the source roam instance
** Pass 1: Move content
*** For each file
**** Get its title
**** and any aliases
**** If none of those is in the ignore list
***** Get all notes this note links to
****** the full link text
****** the name of the link target
***** See if target roam...
****** ...has a matching note for title or alias
****** If not found
******* Create a new note in the target
******* insert title and aliases
******* log note creation
****** Get note in target
- This should now exist as it was either located or created in the previous setp
****** Insert source note content
****** Log note content was transferred
**** Return files in the target and all links that were in the content that was moved
** Pass 2: Recalculate links
*** For each note modified/created in the target in Pass 1
**** For each of its (now) outdated links
***** Look up the proper link for that name
***** Replace the link
**** Log number of links replaced
…of which the only bits I actually know how to do is to org-roam-find-file
and to get aliases eg.
(save-window-excursion
(save-excursion
(find-file "/Users/gmauer/Dropbox (Personal)/org/roam/20200704164319-emacs_lisp.org")
(org-roam--extract-titles-alias)))
The rest I have no idea.
So
Question 1:
Does the above reasoning about why its not straightforward make sense? Have I explained the issue well? Am I missing anything?
Question 2:
Does the above plan for how to script this make sense?
Question 3:
Anyone want to help me figure out how to do any of that stuff?