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

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


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.


cd /path/to/directories &&find . -type d -exec mkdir -p -- /path/to/backup/{} \;


Here is a simple solution using rsync:

rsync -av -f"+ */" -f"- *" "$source" "$target"
  • one line
  • no problems with spaces
  • preserve permissions

I found this solution there