If you use library Dired+ then this is simple.
Just use M-+ M-i
(command diredp-insert-subdirs-recursive
).
Alternatively, use menu Multiple
> Marked Here and Below
> Insert Subdirs
.
Dired+ has many commands that act on the marked files and the marked files in marked subdirectories, gathered recursively. And when none are marked, these commands act on all files in all subdirectories. All such commands are on prefix key M-+
.
Even if some files or subdirs are marked, such commands ignore the markings and act on all files in all subdirectories if you provide a prefix argument.
diredp-insert-subdirs-recursive is an interactive compiled Lisp
function in dired+.el
.
(diredp-insert-subdirs-recursive &optional IGNORE-MARKS-P)
Insert the marked subdirs, including those in marked subdirs.
Like diredp-insert-subdirs
, but act recursively on subdirs.
The subdirs inserted are those that are marked in the current Dired
buffer, or ALL subdirs in the directory if none are marked. Marked
subdirectories are handled recursively in the same way (their marked
subdirs are inserted...).
With a prefix argument, ignore all marks - include all files in this
Dired buffer and all subdirs, recursively.
find-dired
with no arguments. It will create a dired buffer with all files and directories under a given top level directory.C-u s R RET
.C-u s
is a really useful dired command that lets you edit dired'sls
switches.