Created
April 1, 2020 05:08
-
-
Save jethrokuan/370e14b6cd9b7725b815bbdd0cb923fe to your computer and use it in GitHub Desktop.
Roam Export to Org-roam
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find ./ -iname "*.md" -type f -exec sh -c 'pandoc "${0}" -o "${0%.md}.org"' {} \; | |
rm *.md | |
find ./ -iname "*.org" -type f -exec sh -c 'sed -i -E "s/\[\[(.*)\]\]/\[\[file:\1.org]\[\1\]\]/" "${0}"' {} \; |
This gets me far, thanks @jethrokuan!
The sed expression fails when there are multiple links on the same line:
test.md
- [[a]] [[b]]
test.org
- [[file:a]] [[b.org][a]] [[b]]
I had the same issue with the second command, but the following worked for me instead (which I ran multiple times, since each run will work one one link on the line):
find ./ -iname "*.org" -type f -exec sh -c 'sed -i -E "s/\[\[([a-zA-Z0-9 ]*)\]\]/\[\[file:\1.org]\[\1\]\]/" "${0}"' {} \;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This worked for me on macOS after switching from
sed
togsed
otherwise I would get an error:\1 not defined in the RE
. Thanks!