Find files recursively in Emacs Lisp

To find files recursively in Emacs Lisp, use the directory-files-recursively.1 The first argument is the directory the recursive search starts and the second is a regular expression that matches file basenames.

(directory-files-recursively "." "\\.org$")
("./sub/two.org" "./one.org")

The optional third and fourth arguments allow for including directories and following symlinks.


  1. https://www.gnu.org/software/emacs/manual/html​_node/elisp/Contents-of-Directories.html ↩︎