Emacs: Dired the files under the current directory whose name matches a regular expression?

505 views Asked by At

I want something like find-name-dired, but with a regular expression instead of a shell wildcard. Any ideas?

1

There are 1 answers

0
Drew On

You can do what you ask if you use Dired+.

  1. First, use M-+ M-i, to insert all of the subdirectories here and below into the current Dired buffer - that is, all directories under the current Dired directory.

  2. Next, use % m, to mark all files and directories whose names match a regexp you enter.

  3. Next, use C-M-*, to open Dired on just the files and directories that are marked.

You can also do this another way using Dired+, without bothering to insert descendant subdir directories into the ancestor Dired buffer:

  1. Use M-- M-+ % m to mark all files here and below that match the regexp.

  2. Use M-- M-+ F to open all of the marked files here and below.

Prefix key M-+ has "here-and-below" keys/commands that are similar to commands that act only on the files listed in the current Dired buffer. The commands are essentially the same as those without the prefix key: M-+ % m is the "deep" version of % m, M-+ F is the "deep" version of F, and so on.

(The negative prefix arg (M--) tells these commands to ignore any markings of subdirectories themselves, in this Dired buffer and any Dired buffers for descendant directories.)