Xcopy Command (2024)

The xcopy command is a Command Prompt command used to copy one or more files or folders from one location to another location.

With its many options and ability to copy entire directories, it's similar to, but much more powerful than, the copy command. The robocopy command is also similar but has even more options.

Xcopy Command Availability

This command is available from within the Command Prompt in all Windows operating systems including Windows 11. You can also access the command in MS-DOS as a DOS command.

Xcopy Command (1)

Xcopy Command Syntax

Use the following syntax for the xcopy command:

xcopysource[destination] [/a] [/b] [/c] [/d[:date]] [/e] [/f] [/g] [/h] [/i] [/j] [/k] [/l] [/m] [/n] [/o] [/p] [/q] [/r] [/s] [/t] [/u] [/v] [/w] [/x] [/y] [/-y] [/z] [/exclude:file1[+file2][+file3]...] [/?]

The availability of certain xcopy command switches and other command syntax may differ from operating system to operating system. Learn how to read command syntax if you're not sure how to read the syntax above or in the table below.

Xcopy Command Options
ItemDescription
sourceThis defines the files or top level folder that you want to copy from. The source is the only required parameter. Use quotes around source if it contains spaces.
destinationThis option specifies the location where the source files or folders should be copied to. If no destination is listed, the files or folders will be copied to the same folder you run the xcopy command from. Use quotes around destination if it contains spaces.
/aUsing this option will only copy archive files found in source. You can not use /a and /m together.
/bUse this option to copy the symbolic link itself instead of the link target. This option was first available in Windows Vista.
/cThis option forces xcopy to continue even if it encounters an error.
/d [:date]Use the command with /d option and a specific date, in MM-DD-YYYY format, to copy files changed on or after that date. You can also use this option without specifying a specific date to copy only those files in source that are newer than the same files that already exist in destination. This is helpful when using xcopy to perform regular file backups.
/eWhen used alone or with /s, this option is the same as /s but will also create empty folders in destination that were also empty in source. The /e option can also be used together with the /t option to include empty directories and subdirectories found in source in the directory structure created in destination.
/fThis option will display the full path and file name of both the source and destination files being copied.
/gUsing xcopy with this option allows you to copy encrypted files in source to a destination that does not support encryption. This option will not work when copying files from an EFS encrypted drive to a non-EFS encrypted drive.
/hThe command doesn't copy hidden files or system files by default but will when using this option.
/iUse the /i option to force xcopy to assume that destination is a directory. If you don't use this option, and you're copying from source that is a directory or group of files and copying to destination that doesn't exist, the xcopy command will prompt you enter whether destination is a file or directory.
/jThis option copies files without buffering, a feature useful for very big files. This option was first available in Windows 7.
/kUse this option when copying read-only files to retain that file attribute in destination.
/lUse this option to show a list of the files and folders to be copied... but no copying is actually done. The /l option is useful if you're building a complicated command with several options and you'd like to see how it would function hypothetically.
/mThis option is identical to the /a option but xcopy will turn off the archive attribute after copying the file. You can not use /m and /a together.
/nThis option creates files and folders in destination using short file names. This option is only useful when you're using the command to copy files to a destination that exists on an drive formatted to an older file system like FAT that does not support long file names.
/oRetains ownership and Access Control List (ACL) information in the files written in destination.
/pWhen using this option, you'll be prompted before the creation of each file in destination.
/qA kind of opposite of the /f option, the /q switch will put xcopy into "quiet" mode, skipping the on-screen display of each file being copied.
/rUse this option to overwrite read-only files in destination. If you don't use this option when you want to overwrite a read-only file in destination, you'll be prompted with an "Access denied" message and the command will stop running.
/sUse this option to copy directories, subdirectories, and the files contained within them, in addition to the files in the root of source. Empty folders will not be recreated.
/tThis option forces the xcopy command to create a directory structure in destination but not to copy any of the files. In other words, the folders and subfolders found in source will be created but there we be no files. Empty folders will not be created.
/uThis option will only copy files in source that are already in destination.
/vThis option verifies each file as it's written, based on its size, to make sure they're identical. Verification was built in to the command beginning in Windows XP, so this option does nothing in later versions of Windows and is only included for compatibility with older MS-DOS files.
/wUse the /w option to present a "Press any key when ready to being copying file(s)" message. The command will begin copying files as instructed after you confirm with a key press. This option is not the same as the /p option which asks for verification before each file copy.
/xThis option copies file audit settings and System Access Control List (SACL) information. You imply /o when you use the /x option.
/yUse this option to stop the command from prompting you about overwriting files from source that already exist in destination.
/-yUse this option to force the command to prompt you about overwriting files. This might seem like a strange option to exist since this is the default behavior of xcopy but the /y option may be preset in the COPYCMD environment variable on some computers, making this option necessary.
/zThis option allows the xcopy command to safely stop copying files when a network connection is lost and then resume copying from where it left off once the connection is reestablished. This option also shows the percentage copied for each file during the copy process.
/exclude:file1[+file2][+file3]...This option allows you to specify one or more file names containing a list of search strings you want the command to use to determine files and/or folders to skip when copying.
/?Use the help switch with xcopy to show detailed help about the command. Executing xcopy /? is the same as using the help command to execute help xcopy.

Xcopy Command Examples

Following are several examples of how to use this command:

Copy Files to a New Folder

 xcopyC:\FilesE:\Files/i

In the above example, the files contained in thesourcedirectory ofC:\Filesare copied todestination, a new directory [/i] on theEdrive calledFiles.

No subdirectories, nor any files contained within them, will be copied because the/soption was not used.

Xcopy Backup Script

 xcopy"C:\ImportantFiles"D:\Backup/c/d/e/h/i/k/q/r/s/x/y

In this example, xcopy is designed to function as a backup solution. Try this if you'd like to use xcopy instead of abackupsoftware programto back up your files. Put the command as shown above in a script and schedule it to run nightly.

As shown above, the command is used to copy all the files and folders [/s] newer than those already copied [/d], including empty folders [/e] and hidden files [/h], fromsourceofC:\Important Filesto thedestinationofD:\Backup, which is a directory [/i]. Wehave some read-only files we want to keep updated indestination[/r] and we want to keep that attribute after being copied [/k]. We also want to make sure we maintain any ownership and audit settings in the files we're copying [/x]. Finally, since we're running xcopy in a script, we don't need to see any information about the files as they're copied [/q], We don't want to be prompted to overwrite each one [/y], nor do we want the command to stop if it runs into an error [/c].

Copy Files and Folders Over the Network

 xcopyC:\Videos"\\SERVER\MediaBackup"/f/j/s/w/z

Here, the command is used to copy all the files, subfolders, and files contained in the subfolders [/s] fromsourceofC:\Videosto the destination folderMedia Backuplocated on a computer on the network by the name ofSERVER. We're copying some really large video files, so buffering should be disabled to improve the copy process [/j], and since we're copying over the network, we want to be able to resume copying if we lose the network connection [/z]. Being paranoid, we want to be prompted to start the process before it actually does anything [/w], and we also want to see every detail about what files are being copied as they're being copied [/f].

Duplicate Folder Structure

 xcopyC:\Client032C:\Client033/t/e

In this final example, we have asourcefull of well-organized files and folders inC:\Client032for a client. We've already created an emptydestinationfolder,Client033, for a new client but we don't want any files copied—just the empty folder structure [/t] so that we're organized and prepared. We have some empty folders inC:\Client032that might apply to the new client, so we want to make sure those are copied as well [/e].

Save the sometimes lengthy output of the xcopy command to a file using a redirection operator. Learn how to redirect command output to a file or check out our list of Command Prompt Tricks for more tips.

Xcopy & Xcopy32

In Windows 98 and Windows 95, two versions of the xcopy command were available: xcopy and xcopy32. However, the latter command was never intended to be run directly.

When you execute xcopy in Windows 95 or 98, either the original 16-bit version is automatically executed (when in MS-DOS mode) or the newer 32-bit version is automatically executed (when in Windows).

To be clear, no matter what version of Windows or MS-DOS you have, always run the xcopy command, not xcopy32, even if it's available. When you execute xcopy, you're always running the most appropriate version of the command.

Xcopy Related Commands

The xcopy command is similar in many ways to the copy command but with significantly more options, like the ability to copy folders, copy every file in subdirectories, and exclude files.

This command is also very much like the robocopy command except that robocopy has more flexibility than even xcopy.

The dir command is often used with xcopy to check which folders and files are in a directory before completing the command.

FAQ

  • What is the difference between the copy and xcopy commands?

    While the copy command can also be used to move files, xcopy supports additional switches that allow you to do things like move entire directory trees and remove read-only attributes from protected files. When you provide the path of a folder, xcopy copies the folder itself along with its contents (rather than just the files).

  • What is the difference between xcopy and robocopy?

    Robocopy supports different switches for copying files across a network. While you can technically do that with xcopy, robocopy is typically faster, and it will automatically retry if a copy attempt fails.

Was this page helpful?

Thanks for letting us know!

Get the Latest Tech News Delivered Every Day

Subscribe

Tell us why!

Xcopy Command (2024)
Top Articles
How a Small Apartment Can Qualify for Home Office Deduction
India's First Online Zakat Based Crowdfunding Website
No Hard Feelings (2023) Tickets & Showtimes
Kmart near me - Perth, WA
Po Box 7250 Sioux Falls Sd
Ross Dress For Less Hiring Near Me
Brendon Tyler Wharton Height
Overnight Cleaner Jobs
Davante Adams Wikipedia
Dee Dee Blanchard Crime Scene Photos
Gt Transfer Equivalency
Orlando Arrest and Public Records | Florida.StateRecords.org
Darksteel Plate Deepwoken
Jc Post News
Playgirl Magazine Cover Template Free
Fool’s Paradise movie review (2023) | Roger Ebert
Nashville Predators Wiki
Weepinbell Gen 3 Learnset
Pinellas Fire Active Calls
Craigslist Pearl Ms
Contracts for May 28, 2020
Aol News Weather Entertainment Local Lifestyle
Egizi Funeral Home Turnersville Nj
Crossword Help - Find Missing Letters & Solve Clues
Is Holly Warlick Married To Susan Patton
Dashboard Unt
The Eight of Cups Tarot Card Meaning - The Ultimate Guide
Arlington Museum of Art to show shining, shimmering, splendid costumes from Disney Archives
Lacey Costco Gas Price
Spirited Showtimes Near Marcus Twin Creek Cinema
Evil Dead Rise Showtimes Near Regal Sawgrass & Imax
Rock Salt Font Free by Sideshow » Font Squirrel
Craigslist Free Puppy
Boondock Eddie's Menu
What Is Xfinity and How Is It Different from Comcast?
Song That Goes Yeah Yeah Yeah Yeah Sounds Like Mgmt
Aveda Caramel Toner Formula
Nearest Ups Office To Me
Infinite Campus Parent Portal Hall County
Directions To The Closest Auto Parts Store
Weather Underground Cedar Rapids
Silicone Spray Advance Auto
Jammiah Broomfield Ig
Professors Helpers Abbreviation
10 Types of Funeral Services, Ceremonies, and Events » US Urns Online
Doe mee met ons loyaliteitsprogramma | Victoria Club
Mejores páginas para ver deportes gratis y online - VidaBytes
Meee Ruh
Steam Input Per Game Setting
Powah: Automating the Energizing Orb - EnigmaticaModpacks/Enigmatica6 GitHub Wiki
300 Fort Monroe Industrial Parkway Monroeville Oh
Craigs List Sarasota
Latest Posts
Article information

Author: Roderick King

Last Updated:

Views: 6129

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Roderick King

Birthday: 1997-10-09

Address: 3782 Madge Knoll, East Dudley, MA 63913

Phone: +2521695290067

Job: Customer Sales Coordinator

Hobby: Gunsmithing, Embroidery, Parkour, Kitesurfing, Rock climbing, Sand art, Beekeeping

Introduction: My name is Roderick King, I am a cute, splendid, excited, perfect, gentle, funny, vivacious person who loves writing and wants to share my knowledge and understanding with you.