Skip to content

Instantly share code, notes, and snippets.

@jethrokuan
Created April 1, 2020 05:08
Show Gist options
  • Save jethrokuan/370e14b6cd9b7725b815bbdd0cb923fe to your computer and use it in GitHub Desktop.
Save jethrokuan/370e14b6cd9b7725b815bbdd0cb923fe to your computer and use it in GitHub Desktop.
Roam Export to Org-roam
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}"' {} \;
@jackbaty
Copy link

jackbaty commented Apr 9, 2020

This worked for me on macOS after switching from sed to gsed otherwise I would get an error: \1 not defined in the RE. Thanks!

Copy link

ghost commented Apr 11, 2020

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]]

@Todd-Davies
Copy link

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