How to Duplicate a Directory Structure without Files in Windows

On occasion one may wish to duplicate a directory structure but not the files within the original directories. For example, a group of monthly reports may be organized within a set of directories that must be replicated each month.

Windows’ default cut/copy/paste functions copy everything within the selected directory structure. But custom copy functions can be executed using the ‘xcopy’ command at the command line, including copying directories without the files within them.

  1. Enter the command line interface (Windows XP: choose Command Prompt from the Accessories Start menu or just Run ’cmd’; Windows 7: search and click ‘Command Prompt’ from the Start menu)
  2. Type ‘xcopy’, followed by the path to the directory you want to copy, followed by the directory you want to paste to, followed by ‘/T’. For example:xcopy C:\original-directory C:\new-directory /T

This will copy any subdirectories within the ‘original-directory’ into the ‘new-directory’ with one exception – directories without any files in them will not be duplicated. To include empty directories as well, include the /E command after the /T command.

While Windows interface allows for paths and directory names that include spaces, the Command Prompt interface does not, so you must account for this either by eliminating spaces in the directory names you are working with, or by enclosing those paths in quotes, such as “C:\original directory”.

There are many other custom copy commands available using xcopy at the Windows Command Prompt. For a full list, see the Microsoft documentation.

Leave a Reply

You must be logged in to post a comment.