Linux – Copy top level folder structure without copying files in linux

linux

I would like to copy a folder structure (without the files), but only the top level folders. That is, with my source:

folder a
 * folder 1
 * folder 2
   * folder X
folder b
 * folder 3
folder c

I want my destination to simply be:

folder a
folder b
folder c

How can I do this in Linux?

Best Answer

With GNU find, which supports -printf, and GNU xargs, which supports -r:

find /source/path -mindepth 1 -maxdepth 1 -type d -printf '/target/path/%f\0' | xargs -r -0 -- mkdir --
Related Question