I am looking for a way to open all Org (or Fountain) files in a folder using one function.

Essentially, I am seeking to open all available files of a certain type (.org or .fountain) within a folder tree.

  • Welcome. Could you please ellaborate. Do want to open all files individually or just get a directory listing? Commented Dec 8, 2018 at 11:27
  • I should have been a bit more descriptive :) I am seeking to open all available files within a folder tree. The answer by Harald is exactly what I was looking for. Commented Dec 9, 2018 at 6:05
  • 1
    Very good. You should accept his answer, and add the extra explanation of your problem to the body of your question. Commented Dec 9, 2018 at 16:07
  • Thanks, Andrew, I am still learning how to use StackExchange properly. Commented Dec 10, 2018 at 4:47
  • No problem. We are here to help. Commented Dec 10, 2018 at 7:01

1 Answer 1


Here is a solution for org files. I wouldn't recognise a Fountain file if I saw one, so you'd have to provide that one yourself. The second argument to directory-files-recursively is a regular expression.

(defun open-org-files-recursively (dirname)
  "Search DIRNAME recursively for org files, and open them all."
  (interactive "D")
  (mapc #'find-file (directory-files-recursively dirname "\\.org$" nil)))

Edit: The last argument to directory-files-recursively should be nil, in order to exclude directories whose name ends with .org.

  • 1
    Great. This function motivates me to learn some elisp. By the way, fountain files are .fountain, and they are a major mode to write theatre or screen scripts. Commented Dec 9, 2018 at 6:01
  • 1
    @PeterPrevos if you are going to attack elisp, I recommend taking the time to wade through the elisp tutorial, with the elisp manual as a supplement, rather than focusing on the elisp manual directly.
    – zugzwang
    Commented Dec 9, 2018 at 21:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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