Copy directory structure without copying files, on Mac OS X

user@osx:~/from$ find . -type d -exec mkdir -p ~/to/{} \;
user@osx:~/from$ find . -type f -exec ln -s ~/from/{} ~/to/{} \;

or

user@osx:~/from$ find . -type f -exec touch ~/to/{} \;

Try lndir. From its man page:

The lndir program makes  a  shadow  copy  todir  of  a  directory  tree
fromdir,  except  that  the shadow is not populated with real files but
instead with symbolic links pointing at the real files in  the  fromdir
directory tree.

Another solution that works for me is to use rsync and exclude all files, e.g.

$ rsync -a /path/from/ /path/to/ --include \*/ --exclude \*

The --include \*/ specifies that all directories should be copied, and --exclude \* specifies that all files should be excluded from the copy.

The beauty of this is that the new directory hierarchy has the same attributes, timestamps, permissions, etc as the original.


Here's one more variation of the rsync method, which will keep folder icons and finder labels:

rsync -Ea /path/from/ /path/to/ --include="*/"  --include="Icon*" --exclude="*"

This doesn't copy file aliases, so you might want to combine it with whitequark's answer above.