You want to copy a bundle of directories exactly, but without their contents. That is, you want to preserve owner, group, permissions, timestamps. cp -a and rsync -a would do it if you also want the contents. To do this just for top-level directories, you can use

rysnc -dogpt sourcecontainer targetcontainer

That’s very useful when sourcecontainer holds a bundle of directories with specific ownership and permissions that need to be preserved, eg when starting a new web app

rysnc -dogpt /srv/existing_web_app/ /srv/new_web_app

NB: The ‘/’ at the end of sourcecontainer copies its contents to the target. If you only want a specific directory, name that directory as the source but don’t have a ‘/’ at the end. I think things work safest when source and target are absolute paths (as in the example).

Possibly an easier invocation to remember is

rsync -ad --no-r sourcecontainer targetcontainer

the ‘d’ being for copying directories even without their contents.

See also: Using rsync to copy paths


Some useful notes on which bits of C:\WINDOWS can be deleted: