In Emacs how can I search a directory and all subdirectories for a filename?

link|improve this question

65% accept rate
feedback

3 Answers

You can open: */foo.bar for finding any files named foo.bar in a direct subdirectory of the current one, or **/foo.barfor finding any files named foo.bar recursively in subdirectories of the current one.

link|improve this answer
feedback

In dired, you can list all the subdirectories of the visited directory by moving to the first line and pressing C-u l and adding the R switch. You can then search the file name in the buffer, or mark files based on a regexp with % m.

On Linux, or Windows with Cygwin utilities, or other unix-like system with GNU find, a quick-and-dirty hack is M-x grep-find, and edit the command line to contain just the find part with a suitable format:

find -type f -name '*.foo' -printf '%p:0:\n'

On any system that has unix tools available, you can run the find command with M-! find. In the output buffer, you can use M-x ffap to visit the chosen file. You can also set up dired-x so that C-u C-x C-f can be used instead of M-x ffap.

link|improve this answer
feedback

In emacs 23, try M-x find-dired

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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