Question

How to copy folder structure

I want to recreate my folder structure without copying the current files in the folder.

Is this possible with somesort of a command or should I do it manually folder by folder?

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I’ve just found out a small bug in the above commands. If you have spaces in your directory names, the above won’t work properly.

In such a case, you can actually use the following :

find . -type d -print0 >dirs

As soon as the above has finished execute :

xargs -0 mkdir -p <dirs

Regards, KDSys

Hi @fkutev,

You can use just the find command. Here is how I would do it

find . -type d > dirs

Once you have your directories in the dirs file, you can make execute the following command to actually create them

xargs mkdir -p < dirs

This will create the directories you wish.

Regards, KDSys