Skip to content

Instantly share code, notes, and snippets.

@danlamanna
Created March 3, 2013 03:12
Show Gist options
  • Save danlamanna/5074315 to your computer and use it in GitHub Desktop.
Save danlamanna/5074315 to your computer and use it in GitHub Desktop.
(defun recursive-find-dirs(dir-name dir &optional working-dirs)
"find all directories with the name DIR-NAME within DIR, recursively."
(print working-dirs)
(setq working-dirs (or working-dirs '()))
(let ((dirs (directory-files-and-attributes dir t directory-files-no-dot-files-regexp)))
(when dirs
(dolist (current-dir dirs)
(when (file-directory-p (car current-dir))
(if (string-equal (car (last (split-string (car current-dir) "/"))) dir-name)
(push (car current-dir) working-dirs))
(recursive-find-dirs dir-name (car current-dir) working-dirs)))))
working-dirs)
;; print shows that it always (at some point) has all of the directories found correctly,
;; however one or more somehow get removed. also it always RETURNS nil.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment