54

I've got hundreds of personal notes stored as files in Markdown format, after several years using the VoodooPad personal wiki software for OS X.

There's plenty of information available for exporting from org mode to Markdown, but is there an easy way to convert Markdown to org mode format?


Update

Thanks to user2619203's answer and this answer to a question on batch processing of files with Pandoc I was able to convert four hundred Markdown files into org mode format in just a few minutes.

The solution was to export the VoodooPad document to a folder as text (File > Export Document > Export as Text...). Then call pandoc via the find command to convert them all in one go:

$ find . -name \*.txt -type f -exec pandoc  -f markdown -t org -o {}.org {} \; 

The converted .org files I've looked at are formatted beautifully -- even the codeblocks and format styling. Thank-you, user2619203.

To simply convert one file from Markdown to Org the following command can be used:

pandoc -f markdown -t org -o newfile.org original-file.markdown

Here is a link to the Pandoc documentation

1
  • Since you are using pandoc you might be interested in pandoc-mode for emacs, its pretty neat Sep 10 '15 at 13:55
47

Pandoc can convert between multiple document formats.

To convert a bunch of Markdown files to org-mode:

for f in `ls *.md`; do 
  pandoc -f markdown -t org -o ${f}.org ${f}; 
done
4
  • 18
    Please consider adding more substance, such as a link to a relevant part of documentation, a particular pandoc command to use, a minimal working example. See How do I write a good answer?. (In its present form this is more of a comment than an answer.) Dec 17 '14 at 2:34
  • Found the relevant documentation at johnmacfarlane.net/pandoc/README.html
    – Steve HHH
    Dec 17 '14 at 2:44
  • 1
    Not related to pandoc, but for the shell, consider using for f in *.md instead of ls *.md for this purpose. See the great bash wiki for a detailed explanation. Jul 27 at 18:56
  • 1
    Also, using bash parameter expansion, we can remove the md extension so that the resulting files are just like "foo.org" instead of "foo.md.org": for f in *.md ; do pandoc -f markdown -t org -o "${f%%.md}".org "$f" ; done Jul 27 at 19:01
4

Here is an emacs function that will convert the current buffer's content to orgmode format using pandoc:

  (defun markdown-convert-buffer-to-org ()
    "Convert the current buffer's content from markdown to orgmode format and save it with the current buffer's file name but with .org extension."
    (interactive)
    (shell-command-on-region (point-min) (point-max)
                             (format "pandoc -f markdown -t org -o %s"
                                     (concat (file-name-sans-extension (buffer-file-name)) ".org"))))
4

Try this new cool package: org-pandoc-import.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.