; Invoke with ; ; emacs -batch -l batch-replace.el target-string replacement-string file ; > what-ever-destination ; ; For > 1 file, use foreach at shell. ; (defun dot () (point)) (setq target-string (nth 3 command-line-args)) (setq replacement-string (nth 4 command-line-args)) (setq file (nth 5 command-line-args)) (find-file file) (replace-string target-string replacement-string) (setq x (buffer-string)) ;(message (concat (int-to-string (length) x) "")) ;(message (buffer-string)) (beginning-of-buffer) (while (not (eobp)) (progn (setq d (dot)) (end-of-line) (message "%s" (buffer-substring d (dot))) (beginning-of-line) (forward-line 1) ) ) (kill-emacs)