Copying one directory tree to another but exclude all top-level files

Brian J. Murrell brian at interlinx.bc.ca
Fri Jan 30 14:42:23 UTC 2026


On Fri, 2026-01-30 at 08:56 -0500, Kevin Korb via rsync wrote:
> It sounds like you want: --include='/*' --exclude='/*/'

No.  That doesn't work either.

> but I am having 
> a bit of trouble understanding your goal.

Unfortunately I'm not sure how to make it any more clear than I did
already.

I want to copy a directory tree to another location but not copy any
**files** at the top of the tree.

Using `--exclude-from <(find . -maxdepth 1 -type f -printf "%P\n")`
instead of `--exclude *` achieves the goal (so maybe that is more
illustrative of my goal), but I was hoping to achieve the goal without
having to involve an external process.  I.e. with just --include/--
exclude switches.

> You are right though that an 
> exclude of * means exclude everything.

Indeed.

> BTW, a second -v enables include/exclude debugging.

Thanks.

Cheers,
b.



More information about the rsync mailing list