Recreating directory structures can be a tedious and error-prone chore when using the right-click method, especially if it’s necessary to create multiple structures and folders. This guide describes several methods for copying directory structures (without files) in Windows, including using the command line, graphical user interface utilities dedicated for that purpose, and configuring a freeware file manager, FreeCommander, to enable this function.
With the Command-line
For those comfortable with the command-line, two commands that can be used for this purpose are the Xcopy and Robocopy commands; both have tons of options. Although other commands, such as the FOR command, can also copy directory structures, Xcopy and Robocopy are by far the most popular tools used for this purpose.
Xcopy is included in systems up to WinXP. It’s a more powerful version of copy with additional features that can be used to copy files, directories, and whole drives. Xcopy has been deprecated on Windows systems since Vista.
To use Xcopy to clone a directory without files, use the following syntax:
xcopy /t /e "C:\Your Folder" "C:\New Folder"
/t = Copies the subdirectory structure, but not the files
/e = Copies subdirectories, including empty ones
Note: When using Xcopy with the above switches, you will be asked to specify if the target is a directory or a file before the Xcopy command executes.
Additional Xcopy commands can be found here.
Robocopy stands for “Robust file copy.” It’s a standard feature for Windows starting with Vista. It’s can also be installed in WinXP as part of the Windows Resource Kit.
To use Robocopy to clone a directory without files, use the following syntax:
robocopy "C:\Your Folder" "C:\New Folder" /e /xf *
same as above but without displaying status:
robocopy "C:\Your Folder" "C:\New Folder" /e /xf * >null
same as above and create a log:
robocopy "C:\Your Folder" "C:\New Folder" /e /xf * /log:yourlogfile.txt
/e = Copies subdirectories, including empty ones.
/xf = Excludes files matching the specified names or paths. Wildcards “*” and “?” are accepted
Additional Robocopy commands can be found here.
Freeware GUI Utilities
Two easy-to-use GUI (graphical user interface) apps dedicated specifically to creating directory structures without files are listed below:
TreeCopy – Portable and freeware. Runs on Win95 to Win7.
Miroirs - Freeware. Requires installation. Runs on XP/Vista/Win7
Using a File Manager
FreeCommander can be setup to copy directory structures using a batch file with the Xcopy or Robocopy commands. FreeCommander Ver. 2009.02b used for this guide. The following instructions were modified from those provided on the FreeCommander forums as follows:
Create a batch file with the following code and save it, for instance as copyFolderStructure_freecommander.bat. If using Xcopy the file will contain:
xcopy %1 %2 /t /e REM
If using Robocopy the file will contain (or use any of the other options as shown above for Robocopy):
robocopy %1 %2 /e /xf * REM
Note: a pause can be entered at the end of either of the batch files above for viewing command output and troubleshooting errors
From the menu, select Extras->Favorite Tools->Edit or use (SHIFT+CONTROL+Y). Click image below to enlarge.
Click the left-hand column and create a Category if none exists, for instance File Tools. Click image below to enlarge.
Click the right-hand item list and create an item, for instance Copy Folder Structure
Use seek by clicking the blue arrow next to the program field to navigate and enter the saved batch file’s (copyFolderStructure_freecommander.bat) location into the program field
Enter the following into the parameter field:
"%LeftDir%" "%RightDir%" %Dlg%
The above code passes the address of the left and right folder to the batch file. The %Dlg% code displays a window before starting the script, where the folder names can be verified before executing. The operation can also be cancelled. This code can be omitted if desired.
If desired, add an icon by using the blue button next to the icon field to navigate to the icon’s location
Make sure the boxes are checked as in the screen shot above before hitting OK
The toolbar should now contain an icon for copying Folder Structures. Alternately, you can select the tool from the menu by selecting Extras->Favorite Tools->Name of your tool