Copy Folder Structure Without Files in Windows
In this article
To copy only a folder structure (all subfolders, no files) in Windows, use the command robocopy "source" "destination" /E /XF * in Command Prompt. This copies every folder and subfolder while excluding all files, preserving the directory tree exactly.
Why Copy a Folder Structure Without Files?
There are several practical reasons to duplicate just the folder hierarchy. You might be setting up a new project and want the same organizational skeleton for different clients or years. You could be preparing a shared drive for a team, creating a template for document management, or testing backup software with a realistic structure but no bulky files. Another common use is archiving: you want to preserve the folder layout for reference without duplicating gigabytes of data. Whatever the reason, Windows offers built-in tools that handle this task without third-party software.
How Robocopy Works for This Task
Robocopy (Robust File Copy) is a command-line tool included with Windows since Vista. It is designed for high-performance copying with many options. The command robocopy source destination /E /XF * works by:
- /E – copies all subdirectories, including empty ones.
- /XF * – excludes all files (the asterisk matches any file name).
Without /XF *, robocopy would copy files too. With /E, even empty folders are recreated. If you want to skip empty folders, use /S instead of /E (but note that /S only copies directories that contain files, so it may not be ideal for a pure structure copy).
Step-by-Step: Using Robocopy
- Open Command Prompt (press Win + R, type cmd, and press Enter).
- Type the command with your actual paths. For example:
robocopy C:\Users\YourName\Documents\Project C:\Users\YourName\Documents\Project_Copy /E /XF * - Press Enter. Robocopy will display a summary showing folders copied, files skipped, and any errors.
Note that robocopy creates the destination folder automatically if it doesn't exist. Also, if the destination already has folders, robocopy will merge them, not overwrite existing folders unless files are being copied.
Alternative Methods: Xcopy and PowerShell
If you prefer a different tool, Xcopy (an older command) can also do this, but with a quirk. The command xcopy source destination /T /E copies the folder structure. The /T switch copies only the directory tree, and /E includes empty folders. However, xcopy will prompt if the destination is a file or directory; you can avoid this by adding /I to assume the destination is a directory. So: xcopy source destination /T /E /I.
For PowerShell users, you can use the Copy-Item cmdlet with a filter, but it's less straightforward. A common approach is:
Get-ChildItem -Path "source" -Recurse -Directory | ForEach-Object { New-Item -ItemType Directory -Path ($_.FullName -replace '^source', 'destination') }This script recreates each directory path under the destination.
Common Problems and How to Avoid Them
- Robocopy not recognized – Ensure you are using Command Prompt, not PowerShell, and that you have permission to execute robocopy (it's standard in Windows 10/11).
- Path with spaces – Always enclose paths in double quotes, as shown in the example.
- Hidden or system folders – By default, robocopy copies hidden and system folders if they are part of the directory tree. To exclude them, add
/XA:Hto exclude hidden attributes. - Destination already has files – Robocopy will not delete existing files unless you use the
/PURGEor/MIRoption. For a clean copy, use/PURGEto remove any files in the destination that aren't in the source. - Long paths – If you have paths longer than 260 characters, robocopy can handle them if you add
/256(but this is rare).
Comparing Robocopy, Xcopy, and PowerShell
Robocopy is the most robust for this task because it handles long paths, retries on failure, and gives detailed logs. Xcopy is simpler but lacks some of robocopy's error recovery. PowerShell offers flexibility for complex logic but requires scripting knowledge. For most users, robocopy is the recommended choice because it's built-in, fast, and reliable.
Cost and Safety Considerations
All methods described are free and included with Windows. There is no cost. Safety-wise, these commands only copy; they do not delete anything from the source. However, be careful with the destination path: if you accidentally point to an existing folder with files, robocopy will merge the structure, which may not be what you want. Always double-check the destination path before running the command. Additionally, running commands as an administrator may be required if you are copying to protected system folders.
Frequently Asked Questions
Can I copy folder structure without files using File Explorer?
No, File Explorer does not have a built-in option to copy only the folder structure. You must use Command Prompt, PowerShell, or third-party software.
What does /E do in robocopy?
/E tells robocopy to copy all subdirectories, including empty ones. Without it, empty folders would be skipped.
Will robocopy overwrite existing folders in the destination?
Robocopy will not overwrite folders; it only creates missing ones. If the destination has folders, they remain untouched. To remove extra folders, use /PURGE.
How do I copy only the folder names, not the files, using PowerShell?
Use the script provided above, which iterates through all directories and creates them in the destination.
Is there a way to copy the folder structure including hidden folders?
Yes, robocopy includes hidden folders by default. If you want to exclude them, add /XA:H.
Can I use robocopy to copy folder structure from a network drive?
Yes, robocopy works with network paths as long as you have permission to access them. Just use the UNC path like \\server\share\folder.