1

Emacs 26.1, Windows 10

In my directory: d:/TEMP/test/ I has 2 text files. Also in subdirectories I has 2 text files.

enter image description here

If I want to find all files in directory d:/TEMP/test/ I do:

C-x d d:/TEMP/test/*.txt `RET`

As result it show me all text files. Here result:

enter image description here

Nice. But if I want to find all txt files in subdirectories I use this:

C-x d d:/TEMP/test//.txt RET

But It not work. Not find all txt file in all subdirectories. Show message:

No such directory

Why?

Here result: enter image description here

After press Enter enter image description here

  • When you hit RET your input is taken as a glob pattern. – Drew Nov 22 '18 at 16:07
  • Could you get some example? I need to find all *txt files in current directory and all subdirectories. Thanks. – Alexei Nov 23 '18 at 17:14
1

Use command find-name-dired.

M-x find-name-dired RET my-directory RET *.txt

That opens Dired to a listing of all files matching glob pattern *.txt in and under directory my-directory. The usual Dired features are available in this buffer.

To use find-name-dired you must have a UNIX or GNU/Linux find command. If you use MS Windows then you can install Cygwin or similar, to provide this.


See also library find-dired+.el for enhanced versions of the Emacs find-dired-* commands and some additional ones.

  • I found external package for find/replace files by content and extensions in folder and subfolders - "xah-find" - ergoemacs.org/emacs/elisp-xah-find-text.html . It's not depend from external tool like grep/find. It's create on pure Elisp. – Alexei Nov 28 '18 at 8:48
  • Yes, there are lots of such packages. Icicles, for example, lets you search lots of kinds of containers - including files, by both container (e.g. file) name and container contents (using, e.g., regexp patterns for both). But your question was about Dired and glob patterns. – Drew Nov 28 '18 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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