Tuesday, July 07, 2009

Copy Directory Structure Only

This is a simple one liner for copying a Directory structure, and not the contents.

find * -type d -exec mkdir /new_directory/\{\} \;

Now there are a few caveots to this of course, but they are simple.
First the /new_directory/ has to exist.
Second, you have to run the command from within the directory that you want to copy the structure from.

For example, if I need to copy the structure of /Storage to /newStorage I would:
mkdir /newStorage
cd /Storage
find * -type d -exec mkdir /newStorage/\{\} \;

No comments: