Windows – Batch file to copy folder structure

batchwindows

I want write a batch file that can copy a folder structure. This batch file would copy all folders in the source directory to the destination directory – the files themselves would not be copied.

For example, say there is a folder src with the following structure:

src
src\a\file1
src\a\file2
src\a\b\file1
src\c

The tool would create a dest folder like the following:

dest
dest\a
dets\a\b
dest\c

Is it possible to accomplish this task using a batch file?

Best Answer

Try:

XCopy "src" "dest" /T

Just make sure it's not cyclical.

To include empty directories, add /E:

XCopy "src" "dest" /T /E
Related Question