Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a large directory tree with lots of files.

I would like to re-create the directory structure in a new location, but only the directories, not the files.

I've checked cp's man page, but don't see an argument that will help.

share|improve this question

3 Answers 3

up vote 2 down vote accepted
rsync -av -f"+ */" -f"- *" /.../SOURCE /.../DESTINATION
share|improve this answer
can you explain? – chovy Aug 21 '13 at 6:08
This is explained in man rsync (see section "INCLUDE/EXCLUDE PATTERN RULES"). The option -f adds a filter. "+ */" includes all directories, the following "- *" excludes everything else. – Ansgar Wiechers Aug 21 '13 at 10:46

Found this as have hit a similar need. With a new enough version of rsync, that's your best bet.

If you don't have a recent version of rsync, then this does the trick:

find path/to/source -type -d -exec mkdir path/to/dest/'{}' \; -exec chown --reference='{}' path/to/dest/'{}' \; -exec chmod --reference='{}' path/to/dest/'{}' \;

(A variant of this can be used for permission mirroring)

share|improve this answer
find . -type d -exec mkdir -p ~/to/{} \;

Taken from @whitequark's answer to to this question: Copy directory structure without copying files, on Mac OS X

share|improve this answer
brilliant. thanks. – chovy Aug 21 '13 at 18:05
Don't suppose there's a way to do this whilst maintaining attributes? – Sobrique Dec 11 '14 at 16:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.