Create new empty directory tree from existing tree with files
find . -type d -exec mkdir -p ~/to/{} \;
Taken from @whitequark's answer to to this question: Copy directory structure without copying files, on Mac OS X
rsync -av -f"+ */" -f"- *" /.../SOURCE /.../DESTINATION
Another approach is use the tree
which is pretty handy and navigating directory trees based on its strong options. There are options for directory only, exclude empty directories, exclude names with pattern, include only names with pattern, etc. Check out man tree
Advantage: you can edit or review the list, or if you do a lot of scripting and create a batch of empty directories frequently
Approach: create a list of directories using tree
, use that list as an arguments input to mkdir
tree -dfi --noreport > some_dir_file.txt
-dfi
lists only directories, prints full path for each name, makes tree not print the indentation lines,
--noreport
Omits printing of the file and directory report at the end of the tree listing, just to make the output file not contain any fluff
Then go to the destination where you want the empty directories and execute
xargs mkdir < some_dir_file.txt