Copy folder structure (without files) from one location to another

r00fus picture r00fus · Nov 2, 2010 · Viewed 113.6k times · Source

I want to create a clone of the structure of our multi-terabyte file server. I know that cp --parents can move a file and it's parent structure, but is there any way to copy the directory structure intact?

I want to copy to a linux system and our file server is CIFS mounted there.

Answer

Greg Hewgill picture Greg Hewgill · Nov 2, 2010

You could do something like:

find . -type d > dirs.txt

to create the list of directories, then

xargs mkdir -p < dirs.txt

to create the directories on the destination.