Copy top level folder structure without copying files in linux

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

You could simply do this:

for dir in *; do mkdir /path/to/"$dir"; done

This assumes that you want to copy everything in the current directory and that all you have in that directory are the target folders, no files. It will collect all names in the current directory (*) and run mkdir to create empty folders of that name in the target path.

Tags:

Linux