Bash batch script to convert org-mode file to html

I recently read this on reddit. I adapted the script on there to convert multiple org-mode files to html files. If you use it make sure you adapte the location of org-mode and your org.el file. Enjoy.

 <pre class="src src-sh"><span style="color: #ff4500;">#</span><span style="color: #ff4500;">! /bin/</span><span style="color: #00ffff;">bash</span>

## ## ## f=“” for file in “$@” do ##emacs –batch -q –no-site-file –eval “(add-to-list ‘load-path “~/.emacs.d/org-mode/lisp/”)” –load $HOME/.emacs.d/org-mode/lisp/org.el –visit ${file} –funcall org-export-as-html-batch f=“${f} –visit ${file} –funcall org-export-as-html-batch” done emacs –batch -q –no-site-file –eval “(add-to-list ‘load-path “~/.emacs.d/org-mode/lisp/“)” –load $HOME/.emacs.d/org-mode/lisp/org.el $f ## use emacsclient, check if running, execute. otherwise u this ## NO, emacsclient takes in elisp argument with –eval, not list list of files (will need to write my own elisp function…not worth effort)

About Vinh Nguyen



  1. Pingback: bamanzi
  2. That’s exactly what I needed. Many thanks for sharing!

    It went into my makefile, though as pdf creation instead of html:

    doktorarbeit.pdf : doktorarbeit.tex emacs --batch --visit "" --funcall org-export-as-pdf

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>