How to Copy Folders and Subfolders Using Xcopy Command (2024)

Table of Contents

What is the Xcopy command?

Xcopy, short for extended copy, is a command that allows you to copy multiple files or entire directory trees from one location to another. Unlike the basic copy command, Xcopy offers additional options to specify the source and destination in more detail. It's particularly helpful when copying files from a CD-ROM to a hard drive because it automatically removes the read-only attribute.

Xcopy command is available on most operating systems such as IBM PC DOS, MS-DOS, Windows, and freeDOS. While being functionally replaced by a more powerful copy tool Robocopy, Xcopy is still included in Windows 10, and you can continue using it to copy folders and subfolders.

Can I copy folders and subfolders using the Xcopy command?

How to Copy Folders and Subfolders Using Xcopy Command (2)

I have a folder with a lot of subfolders and files in them. Now, I want to copy the folder to another location, but I don’t want to recreate directory structures. Can I use the Xcopy command to copy the directory structure of the folder and subfolders to another location?

Yes, you can use the Xcopy command to copy folders and subfolders directly. Recreating directory structures manually can be tedious and prone to errors, especially when using the right-click method to create multiple structures and folders. In this article, I'll show you how to achieve this using Xcopy. Keep reading to learn the detailed steps.

However,Xcopy provides a basic folder duplication, but for advanced operations like auto-copying changed files, versioning, and compression, AOMEI Backupper Standard is a reliable free option for Windows PCs. Click the jump link below to get a more flexible and simple free file copy solution!

How to Copy Folders and Subfolders Using Xcopy Command (3)A better way to copy any files & folders

Backup or sync folders and subfolders automatically and flexibly, complete any operation with simple clicks in an intuitive interface. Check this advanced method »

Download FreewareWindows 11/10/8.1/8/7

How to Copy Folders Using Xcopy Command

To move folders and subfolders in cmd, the most used command syntax would be:

xcopy [source] [destination] [options]

And there are plenty of options and switches for different demands. You can copy folders and subfolders including or excluding files from one location to another by following the steps.

Situation 1. copy folders and subfolders and contents

1. Click Start and type cmd in the search box. Right-click Command Prompt from the result list and select Run as administrator. Or you can press Win + R to call up the Run window, and type "cmd" in the textbox.

2. Now, when you're in the Command Prompt, you can type Xcopy command below to copy folders and subfolders including all the contents. For example, if you want to copy the “test” folder and its subfolders on C drive to D drive, type Xcopy command as:

Xcopy C:\test D:\test /E /H /C /I

  • /E – Copy subdirectories, including any empty ones.

  • /H - Copy files with hidden and system file attributes.

  • /C - Continue copying even if an error occurs.

  • /I - If in doubt, always assume the destination is a folder. e.g. when the destination does not exist.

Notes:
· Xcopy will not copy open files.
· Xcopy doesn’t display any progress or completed operations information when executed.
· Remember that for folders with spaces in the name or folders larger than 8 characters in length, it is a good idea to put quotation marks around the path or you may get an error.

Situation 2. copy folders and subfolders without files

Yes, you can use the Xcopy command to copy folders and subfolders directly. Manually recreating directory structures can be tedious and prone to errors, especially when using the right-click method to create multiple structures and folders. To achieve this, open the Command Prompt and follow the steps shown above. Then, type the Xcopy command below to copy folders and subfolders without files.

Xcopy Source Destination /T /E

  • /T - Copy the subdirectory structure, but not the files.

  • /E - Copy subdirectories, including any empty ones.

Situation 3. copy folders and subfolders with NTFS and Share permission

Sometimes, you may need to transfer the NTFS and Share permission together with your folders.

Once the Command Prompt is open, you can then type the following Xcopy command to copy all files and folders and retain its NTFS and Share permissions.

Xcopy Source Destination /O /X /E /H /K

  • /E - Copy folders and subfolders, including empty ones.

  • /H - Copy hidden and system files also.

  • /K - Copy attributes. Typically, Xcopy resets read-only attributes.

  • /O - Copy file ownership and ACL information.

  • /X - Copy file audit settings (implies /O).

Actually, there are many parameters of the Xcopy command, and you can combine different parameters for different situations. But if there is a slight error in the command, the copy operation may fail, and even lead to data loss. Therefore, you must be very careful when using the Xcopy command.

For users who are not familiar with the use of the command line, and want to copy files and folders easily, you can also use a handy backup software.

Versatile &efficient | Copy files or folders in Windows flexibly

Xcopy provides basic folder duplication, but it lacks the advanced features needed for more complex tasks. For operations like auto-copying changed files, versioning, and compression, AOMEI Backupper Standard is a reliable, free option for Windows PCs. This tool offers more comprehensive functionality, making it ideal for users needing robust backup and recovery solutions.

How to Copy Folders and Subfolders Using Xcopy Command (5)

How to Copy Folders and Subfolders Using Xcopy Command (6) AOMEI Backupper

Easy-to-use Folder Copy Tool

  • Flexible Copy options:You can sync folders to maintain their original format & structure, or back them up into image files for recovery.
  • Various Storage devices: Supports various storage options like internal/external drives, USB flash drives, cloud, network shares, and NAS.
  • Automatic Schedule tasks: Scheduled options enable automated backup/sync tasks, with choices for incremental or differential backup to save changed data only.
  • Professional Edition Features: Upgrade for real-time file syncing and auto-deletion of older backup versions to conserve space.

Download FreewareWindows 11/10/8.1/8/7

How to Copy Folders and Subfolders Using Xcopy Command (7) 100% Secure

How to copy files or folders via AOMEI Backupper

Step 1. Launch AOMEI Backupper and select Sync > Basic Sync to copy folders and subfolders.

If you want to backup folders into restorable image files and keep different versions, you can consider Backup options, which are better suited for backing up large data (like partitions, disks, andsystem backup).

In the advanced edition, you can enjoy threemore practical sync modes:
Real-Time Sync: Sync changed files from the source directory to the target directory in real-time.
Mirror Sync: Keep the contents in the target directory exactly the same as the source directory.
Two-Way Sync: Make any changes in the source or target directory be synced to the other side mutually.

Step 2. Click Add Folder to specify the folder and click OK. You can add more folders by clicking the+ button.

Note: After clicking Add Folder, you can open Filter Settings to set file inclusion/exclusion mask (available in Pro and above editions).

Step 3. Select the destination path you want to copy files to. Internal hard drive, connected external hard drive, cloud drive, shared folder, and NAS are all available.

Step 4. (Optional) Click Schedule Sync to enable it, and set a Daily/Weekly/Monthly task as you like.

Step 5. Confirm all your settings and click Start Sync.

⚠️Tips:
· Don't modify the source folder name, otherwise, the program will not sync files/folders anymore.
· If you want to backup folder to a cloud drive but do not have enough space, you could consider creating a cloud backup with AOMEI Cloud, a cloud drive released by AOMEI Tech, which offers you 1TB of free cloud storage space from the date you sign up until 15 days.
· AOMEI Backupper is also a disk cloner that would help you clone a hard drive to an SSD with ease.

    The advantages of Xcopy command

    After learning some basic information about the XCOPY command, it's important to understand its benefits. The advantages of the XCOPY command are listed below:

    ⭐Efficiency in Copying Large Sets of Files: XCOPY can quickly copy multiple files and entire directory trees, making it highly efficient for bulk file transfers.
    ⭐Flexible File Selection: With various switches and options, XCOPY allows precise control over which files and directories are copied.
    ⭐Preservation of File Attributes: XCOPY can maintain file attributes like read-only, hidden, and system, ensuring the copied files retain their original properties.
    ⭐Automatic Removal of Read-Only Attribute: When copying files from read-only media like CD-ROMs, Xcopy can automatically remove the read-only attribute from copied files, simplifying the transfer process.
    ⭐Batch File Integration: Xcopy can be easily integrated into batch files for automated and scheduled file-copying tasks, enhancing automation and efficiency.

    FAQs about Xcopy command

    1. What is the difference between the copy command and Xcopy Robocopy?

    The "copy" command is used for basic file copying, while "Xcopy" allows for copying multiple files and complete directory trees. "Robocopy" replaces "Xcopy" and offers more advanced options and features for copying files and directories.

    2. Does Xcopy copy hidden files?

    By default, the Xcopy command does not copy hidden or system files, but it can with the appropriate options. Using the /h option enables Xcopy to include hidden and system files in the copying process.

    3. Why use Xcopy instead of copy?

    Xcopy is more powerful than the basic copy command, especially useful for backing up entire directories. For instance, using the /S option with the /D option allows you to back up only the files that have changed since your last backup.

    Bottom Line

    You can copy folders and subfolders using the Xcopy command in the steps shown above. However, many users say that copying failed due to Xcopy not working sometimes, or Xcopy does not copy all files. In some cases, Xcopy halts because of an “Insufficient Memory” error or an invalid number of parameters.

    Therefore, using AOMEI Backupper to copy folders or files is a more reliable and convenient method. With only a few clicks, you can copy folders or files to your destination, and its useful features like incremental backup, USB plug-in, etc. bring you much convenience.

    If you want to backup files on any other computers without installation, use AOMEI Backupper Technician or Technician Plus to create a portable AOMEI Backupper. Just give it a shot!

    How to Copy Folders and Subfolders Using Xcopy Command (2024)
    Top Articles
    Customize your Safari settings on iPhone
    Capital Gains Tax Exclusion for Homeowners: What to Know
    Jail Inquiry | Polk County Sheriff's Office
    Cintas Pay Bill
    Booknet.com Contract Marriage 2
    50 Meowbahh Fun Facts: Net Worth, Age, Birthday, Face Reveal, YouTube Earnings, Girlfriend, Doxxed, Discord, Fanart, TikTok, Instagram, Etc
    Mustangps.instructure
    Achivr Visb Verizon
    Optum Medicare Support
    Devourer Of Gods Resprite
    Catsweb Tx State
    Missing 2023 Showtimes Near Lucas Cinemas Albertville
    Los Angeles Craigs List
    Craigslist Pets Athens Ohio
    Erskine Plus Portal
    Mile Split Fl
    Rachel Griffin Bikini
    De beste uitvaartdiensten die goede rituele diensten aanbieden voor de laatste rituelen
    bode - Bode frequency response of dynamic system
    Hyvee Workday
    Fsga Golf
    Busted Mcpherson Newspaper
    Anotherdeadfairy
    Inbanithi Age
    Обзор Joxi: Что это такое? Отзывы, аналоги, сайт и инструкции | APS
    Cal State Fullerton Titan Online
    Times Narcos Lied To You About What Really Happened - Grunge
    WOODSTOCK CELEBRATES 50 YEARS WITH COMPREHENSIVE 38-CD DELUXE BOXED SET | Rhino
    Boneyard Barbers
    Autozone Locations Near Me
    RALEY MEDICAL | Oklahoma Department of Rehabilitation Services
    Cal Poly 2027 College Confidential
    How much does Painttool SAI costs?
    Gateway Bible Passage Lookup
    Devon Lannigan Obituary
    Walmart Car Service Near Me
    Mudfin Village Wow
    How I Passed the AZ-900 Microsoft Azure Fundamentals Exam
    Bmp 202 Blue Round Pill
    Tropical Smoothie Address
    25 Hotels TRULY CLOSEST to Woollett Aquatics Center, Irvine, CA
    Scott Surratt Salary
    Quest Diagnostics Mt Morris Appointment
    Craigslist Sarasota Free Stuff
    Solving Quadratics All Methods Worksheet Answers
    Diamond Spikes Worth Aj
    sin city jili
    Southwind Village, Southend Village, Southwood Village, Supervision Of Alcohol Sales In Church And Village Halls
    2121 Gateway Point
    Att Corporate Store Location
    Latest Posts
    Article information

    Author: Nicola Considine CPA

    Last Updated:

    Views: 6154

    Rating: 4.9 / 5 (49 voted)

    Reviews: 88% of readers found this page helpful

    Author information

    Name: Nicola Considine CPA

    Birthday: 1993-02-26

    Address: 3809 Clinton Inlet, East Aleisha, UT 46318-2392

    Phone: +2681424145499

    Job: Government Technician

    Hobby: Calligraphy, Lego building, Worldbuilding, Shooting, Bird watching, Shopping, Cooking

    Introduction: My name is Nicola Considine CPA, I am a determined, witty, powerful, brainy, open, smiling, proud person who loves writing and wants to share my knowledge and understanding with you.