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?

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.

×
2 answers

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

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

Submit an Answer