linuxfilecopydirectory

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


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.


Solution

  • 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.