How to Recreate a Folder's Structure Without the Files in Windows

Windows makes it easy to copy and paste folders and sub-folders from one directory to another. However, the conventional Ctrl + C and Ctrl + V method copies the entire folder and its contents. Sometimes, you may want to copy the folder structure without its content. With the conventional method, copying and then deleting the contents of each folder becomes tedious.

To remedy this issue, you can use the command line utility in PowerShell. In addition, you can also use command-line utilities such as Xcopy and Robocopy to achieve the same. Here we show some ways to copy a folder's structure without its files on Windows.

1. Use the Duplicate Directory App to Copy the Folder Structure

The easiest way to copy a folder structure without the files is to use a third-party utility called Duplicate Director. It is a multi-platform utility and is available on both Windows and macOS. The developer uses a pay-what-you-want (PWYW) pricing for the app, so you can name a fair price and download the app.

To copy folder structure without files using Duplicate Directory:

  • Go to the Duplicate Directory page and download the Windows version.
  • Run the installer and install the app. Once installed, launch the app from the Start menu.
  • To duplicate the directory, you'll need to select the Source Path and the Destination Path by clicking the appropriate options.
  • Click Duplicate to copy the directory.
  • 2. How to Copy a Folder's Structure Using PowerShell

    If you prefer a built-in method, you can copy the folder structure without files using Windows PowerShell. To duplicate the file structure using PowerShell, you'll need to see the Copy-Item command followed by the source and destination path.

    For this guide, we will duplicate the folder file structure in the path "E:\NewFolder" to the destination path "E:\TestFolder." Here's how to do it.

  • Open PowerShell as an administrator (see how to open PowerShell as an administrator).
  • In the PowerShell window, type the following command:
    Copy-Item -LiteralPath "[SourcePath]" -Destination "[DestinationPath]" -Recurse -Filter {PSIsContainer -eq $true} 
  • The full command with the source and destination paths added will look something like below:
    Copy-Item -LiteralPath "E:\NewFolder" -Destination "E:\TestFolder" -Recurse -Filter {PSIsContainer -eq $true} 
  • You can avoid typing the complete source and destination path by dragging and dropping the folders to the PowerShell console. PowerShell will automatically add the path for the respective folders.
  • The Filter command above uses the PSIScontainer property of the folders, which are containers and have the value True ($true). Hence, select only the folders and leave out all the files inside the folder with the value False ($false).
  • Once the command is executed, the entire NewFolder structure will be available under the TestFolder without the files.
  • 3. How to Copy a Folder's Structure Using the Command Prompt

    In addition to PowerShell, Windows features two other command-line copy utilities called Xcopy and Robocopy, to help you copy files faster on your Windows computer. While Robocopy is designed to be a replacement for the older Xcopy app, both the utilities are functional and come pre-installed in all the editions of the Windows operating system.

    • Xcopy: Short for extended copy, is a command-line utility to copy files and directories, including subdirectories. It supports multiple parameters or switches, including e/ and /t, essential to perform the copy function without the files.
    • Robocopy: The successor to the Xcopy, Robust File Copy (Robocopy), comes with more options such as mirroring, the ability to check the differences in files, and scheduling a copy run.

    Let's explore how to use both of these to copy a folder's structure.

    How to Copy a Folder's Structure Using Xcopy

    Copying a folder's structure with Xcopy is easy. We need to use the "xcopy" command, followed by the source and destination path. In addition, we'll use two Xcopy switches, /t and /e, to duplicate the folder and its sub-directories without copying the files.

    Note that using both switches is necessary to duplicate the directory. While the /t switch can copy the subdirectory structure, it cannot detect empty folders. To remedy the problem, you can use the /e switch, which can copy subdirectories even if the folders are empty.

    To copy an entire directory tree using Xcopy:

  • Press the Win key and type cmd.
  • Right-click on Command Prompt and select Run as administrator.
  • In the Command Prompt window, type the following command:
    xcopy "SourcePath" "DestinationPath"/t /e 
  • In the above command, replace SourcePath with the folder structure you want to copy and DestinationPath with the path where you want to store the duplicated folder.
  • For example, for this guide, the full command will look something like this:
    xcopy "E:\NewFolder" "E:\TestFolder" /t /e 
  • Once done, open your destination path to see if the successfully copied folder structure.
  • How to Duplicate a Folder's Structure Using Robocopy

    Robocopy replaces Xcopy and comes with an additional set of switches and features. Similar to its predecessor, you'll need to use two switches, /e and /xf.

    Where the e/ switch copies the directory, the /xf * switch excludes all files.

    To copy folder structure using Robocopy:

  • Open Command Prompt as above.
  • Type the following command:
    Robocopy "SourcePath" "DestinationPath"/e /xf * 
  • In the above command, replace "SourcePath" and "DestinationPath" with the appropriate directory path. It is important to include the wildcard character * in the command; otherwise, the command will copy the directory with the files in them.
  • The full command with the source and destination path for this guide will look something like below:
    robocopy "E:\NewFolder" "E:\TestFolder" /e /xf * 
  • Recreating an Empty Folder Structure on Windows

    You may want to recreate an empty folder structure for many reasons. This process is likely a monthly or yearly exercise for most people, so using the Command Prompt and PowerShell methods is acceptable.

    That said, if you don't want to take the nerdy route, you can use the Duplicate Directory utility for a simple GUI-based solution. It is free to use unless you wish to pay, and it works on both Windows and macOS running systems.

    ncG1vNJzZmivp6x7rq3KnqysnZ%2Bbe6S7zGiaqKipYrOwuMOeqWarpKfCpMDUq5xmr5mptbDB02adoqSVqHq4tc2dprCrXw%3D%3D