Which Windows command would you use to copy a directory and all its contents?

Article SummaryX

1. Type "cd" followed by a space in command prompt, but don't press "enter" yet.
2. Type the name of the directory your filed is located in.
3. Press "enter."
4. Type "copy" followed by a space, but don't press "enter."
5. Type your file's name followed by a space, but don't press "enter."
6. Type in the name of the directory you want to copy the file to.
7. Press "enter" to copy the file.

Did this summary help you?YesNo

Thanks to all authors for creating a page that has been read 2,095,919 times.

If the file specified as the TargetFile exists, the copy writes over the original contents of the file. If you are copying more than one SourceFile, the target must be a directory.

To place a copy of the SourceFile into a directory, specify a path to an existing directory for the TargetDirectory parameter. Files maintain their respective names when copied to a directory unless you specify a new file name at the end of the path. The cp command also copies entire directories into other directories if you specify the -r or -R flags.

The following are examples of how to use the cp command:

  • To copy all the files in the /home/accounts/customers/orders directory to the /home/accounts/customers/shipments directory, type the following:
    cp /home/accounts/customers/orders/* /home/accounts/customers/shipments
    This copies the files, but not the directories, from the orders directory into the shipments directory.
  • To copy a directory, including all its files and subdirectories, to another directory, type the following:
    cp -R /home/accounts/customers /home/accounts/vendors
    This copies the customers directory, including all its files, subdirectories, and the files in those subdirectories, into the vendors directory.

If you’ve found an effective way to organize your data across folders and subfolders, you probably want to replicate that structure. However, typical ways of copying folders also include duplicating files, so you’ll have to waste time emptying the folders. Fortunately, several methods bypass this issue in Windows 11 and 10, macOS, and Linux-based computers. Continue reading to find out how to duplicate a folder structure without its original files.

Which Windows command would you use to copy a directory and all its contents?

Copy Folder Structure Without Copying Files in Windows 11

Windows File Explorer offers no built-in option of automatically replicating complex folder structures. Going through folder hierarchies and replicating them is tedious and requires time and effort. Luckily for Windows 11 users there are still two other methods to copy folder structures without transferring files.

The first way involves using the Command Prompt. “Xcopy” is short for “extended copy” and this command allows you to transfer folder structures to a new storage location without duplicating the files. The command line uses the “/t” switch to do so. The issue is that the duplicating switch cannot detect empty folders, so it’s necessary to modify it and add the “/e” switch. Combining the two helps the Command Prompt to identify empty folders and copy their organization model. Here’s how to use “xcopy” in the Command Prompt:

  1. Hold “Windows + R” to open the Run dialog.
    Which Windows command would you use to copy a directory and all its contents?
  2. Type “cmd” in the dialog window and click on the “OK” button to launch the Command Prompt.
    Which Windows command would you use to copy a directory and all its contents?
  3. In the Command Prompt window, type the following: "xcopy", "source", "destination" /t /e.
    Which Windows command would you use to copy a directory and all its contents?
  4. Instead of “source,” enter the path that stores the folder structure you want to duplicate.
    Which Windows command would you use to copy a directory and all its contents?
  5. Instead of “destination,” type the path where you want to store the copied hierarchy.
    Which Windows command would you use to copy a directory and all its contents?
  6. Tap “Enter” on the keyboard.

You can also use the Command Prompt with a Robocopy command to copy folder directories, hierarchies, and structures. Microsoft intended for Robocopy to serve as a more functional version of “xcopy,” providing users with more options to manipulate and organize files and folders. You can take the hassle out of copying complicated file directories by typing a relatively short command line. To do so:

  1. Press “Windows + R” to launch the Run dialog.
    Which Windows command would you use to copy a directory and all its contents?
  2. Type “cmd” in the pop-up window.
    Which Windows command would you use to copy a directory and all its contents?
  3. Hold down “Ctrl + Shift + Enter” to enable the “Run as administrator” option.
    Which Windows command would you use to copy a directory and all its contents?
  4. When the Command Prompt window appears, type the following command line: /t0.
    Which Windows command would you use to copy a directory and all its contents?
  5. Replace “source” with the path where the folder structure you wish to copy is located.
    Which Windows command would you use to copy a directory and all its contents?
  6. Replace “destination” with the path where the duplicate structure will be created.
    Which Windows command would you use to copy a directory and all its contents?
  7. Hit the “Enter” key.

The “/e” switch allows the system to copy subhierarchies embedded within the folder structure.

The “/t4” switch adjusts the command line, preventing the system from copying any files kept in the folders.

The second option for Windows 11 users is copying folder structures with third-party software. This is an excellent choice if you don’t feel comfortable working with command lines or are uncertain about your technical knowledge. One of the most user-friendly programs is Duplicate Directory. The developers want you to determine how useful the tool is, so there’s no fixed price tag. The customers can donate any amount they want in order to download the software. To replicate structures with Duplicate Directory:

  1. Download and launch the program.
    Which Windows command would you use to copy a directory and all its contents?
  2. Choose the original folder structure path.
  3. Select the copied folder structure location path.
  4. Press the “Duplicate” button.

The program will replicate all the source folders in a new location without moving or copying the files.

Copy Folder Structure Without Copying Files in Windows 10

Windows File Explorer is useful for manually creating folders for your files, but it has no feature that lets Windows 10 users create copies of folder structures and directories. If you’re working on intricate personal or professional projects, your folders are probably packed with subfolders. Recreating this structure takes a lot of patience and energy. Fortunately, you can use command lines to recreate folder structures with ease.

Command lines act as pseudo-code and are typically used with the Command Prompt to execute various tasks. The “xcopy” command replicates folders, and you can modify it using switches that determine which aspects will be copied or excluded. The “/t” switch signals to the system that it should replicate all folders without the files. Since this function doesn’t register empty folders, the command line will also include the “/e” switch. The system will scan structures containing empty folders and replicate them in their entirety. To execute the command:

  1. Tap “Windows + R” to open the Run dialogue.
    Which Windows command would you use to copy a directory and all its contents?
  2. Type “cmd” and click on “OK” to launch the Command Prompt.
    Which Windows command would you use to copy a directory and all its contents?
  3. Type "xcopy", "source", "destination" /t /e in the Command Prompt window.
    Which Windows command would you use to copy a directory and all its contents?
  4. Instead of “source,” type the path of the folder hierarchy you want to copy.
    Which Windows command would you use to copy a directory and all its contents?
  5. Instead of “destination,” enter the path where you want to store the copied folder structure.
    Which Windows command would you use to copy a directory and all its contents?
  6. Press “Enter” on your keyboard.

Another option is the Robocopy command. Here’s how to copy a folder structure with a Robocopy line:

  1. Click on “Windows + R” to bring up the Run dialog.
    Which Windows command would you use to copy a directory and all its contents?
  2. Type “cmd” in the new window.
    Which Windows command would you use to copy a directory and all its contents?
  3. Hold “Ctrl + Shift + Enter” to run the Command Prompt as administrator.
    Which Windows command would you use to copy a directory and all its contents?
  4. Type /t0 in the Command Prompt window.
    Which Windows command would you use to copy a directory and all its contents?
  5. Replace “source” with the path of the original folder structure.
    Which Windows command would you use to copy a directory and all its contents?
  6. Replace “destination” with the path where you’ll store the copied folder structure.
    Which Windows command would you use to copy a directory and all its contents?
  7. Tap the “Enter” key.

The action will replicate the structure, preserving all subfolders and excluding the original files.

Copy Folder Structure Without Copying Files on a Mac

If you have a MacBook, you can copy a folder structure with a command line or third-party software.

MacOS executes commands using Mac Terminal. To copy a folder structure with the program:

  1. Open the source folder of the structure.
  2. Open the destination folder for the duplicate structure.
  3. Tap the “Launchpad” button and type “Terminal” in the search bar.
    Which Windows command would you use to copy a directory and all its contents?
  4. When it shows up in the search results, tap the program to open it.
    Which Windows command would you use to copy a directory and all its contents?
  5. Type the following command in the Terminal window: /e6
    Which Windows command would you use to copy a directory and all its contents?
  6. Drag and drop the source folder into the window.
  7. Drag and drop the destination folder into Terminal as well.
  8. Press “Enter” from the keyboard.

The action will clone the folder structure in the new location without keeping any original files.

You can also copy structures and hierarchies with the Duplicate Directory software. The app doesn’t involve writing command lines and works on donations. Users can decide how much the program is worth and download it after making a donation. Here’s how to use the software:

  1. Download and launch Duplicate Directory.
    Which Windows command would you use to copy a directory and all its contents?
  2. Pick the source path of the folder structure.
  3. Select the location path of the cloned structure.
  4. Click on the “Duplicate” button.

The program will replicate the folders and subfolders, but won’t preserve the files, allowing you to store and organize new data.

Copy Folder Structure Without Copying Files in Linux

Linux systems let users execute numerous commands, but it’s sometimes challenging to remember all the command lines. The quickest way to copy a folder structure in Linux is with the “rsync” command, a tool for replicating files and directories. Since “rsync” utilities come preinstalled on Linux products, cloning folder hierarchies without files is relatively straightforward. To do so:

  1. Press “Crtl + Alt + T” to open the Terminal app.
  2. Type the following “/e7” command in the Terminal window:/e8
  3. Replace “source” with the path containing the original folder structure.
    Which Windows command would you use to copy a directory and all its contents?
  4. Relace “destination” with the path where the copied structure will be created.
    Which Windows command would you use to copy a directory and all its contents?
  5. Hit the “Enter” key.
    Which Windows command would you use to copy a directory and all its contents?

The modified command line instructs the system to replicate folders and subfolders but skip files.

Replicate Folder Structures Efficiently

Our laptops and PCs help us keep track of personal and professional information and documents, so it’s essential that the data is well-organized. To ensure your data is in order, you can replicate empty folder structures on your device using either command lines or third-party programs.

Have you ever copied a folder hierarchy or directory? Did you use one of the methods outlined in this article? Let us know in the comments section below.

What Windows command can be used to copy entire directories?

Then, xcopy copies all specified files into the new directory. By default, xcopy prompts you to specify whether destination is a file or a directory. Copies directories and subdirectories, unless they are empty. If you omit /s, xcopy works within a single directory.

Which command copy copy entire tree of c :\ windows help to current directory?

Xcopy, stands for extended copy, is a command that can copy multiple files or entire directory trees from one location to another.

What command is used to copy folders and their contents?

The cp Command cp stands for copy. This command is used to copy files or group of files or directories. It creates an exact copy of a file on a disk with different file name. cp command requires at least two filenames in its arguments.

What is the copy command in Windows?

Keyboard Command: Control (Ctrl) + C.