If you use library Dired+ then this is simple.
M-+ M-i (command
Alternatively, use menu
Marked Here and Below >
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
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
(diredp-insert-subdirs-recursive &optional IGNORE-MARKS-P)
Insert the marked subdirs, including those in marked subdirs.
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-diredwith 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 sis a really useful dired command that lets you edit dired's