This is the official manual for the latest Org-mode release.

Table of Contents

Previous: Key bindings and useful functions, Up: Working with source code


14.12 Batch execution

Org mode features, including working with source code facilities can be invoked from the command line. This enables building shell scripts for batch processing, running automated system tasks, and expanding Org mode's usefulness.

The sample script shows batch processing of multiple files using org-babel-tangle.

     #!/bin/sh
     # -*- mode: shell-script -*-
     #
     # tangle files with org-mode
     #
     DIR=`pwd`
     FILES=""
     
     # wrap each argument in the code required to call tangle on it
     for i in $@; do
         FILES="$FILES \"$i\""
     done
     
     emacs -Q --batch \
          --eval "(progn
          (require 'org)(require 'ob)(require 'ob-tangle)
          (mapc (lambda (file)
                 (find-file (expand-file-name file \"$DIR\"))
                 (org-babel-tangle)
                 (kill-buffer)) '($FILES)))" 2>&1 |grep -i tangled