xcopy Command Builder
Build an xcopy command from checkboxes: every switch explained, warnings for prompts that hang scripts, command parsing and a .cmd with exit codes.
xcopy has been in Windows since DOS and is still in every version: quick for copying a folder tree, and still in a lot of old login scripts and batch files. Tick the options you need and the command is built as you go, with each switch explained and warnings for the classic traps: the "file or directory?" prompt that hangs scripts, /EXCLUDE files that aren't wildcards, and copies into themselves. Paste an old command to see what it does. For big, repeated or mirrored jobs, robocopy retries, resumes and logs better. Switch descriptions are based on Microsoft's xcopy reference and checked against xcopy on Windows 11.
Built in your browser. Your paths and options are never sent to tclient.com.
This page runs on your device (WebAssembly), so server, share and host names stay there. A share link is only created when you click Copy link, and it keeps everything after # in the address, which browsers never send to a server.
Start from a preset
Command
xcopy C:\Data D:\Backup\Data /E /H /I /Y /K
Paste an existing command
Source and destination
Command
xcopy C:\Data D:\Backup\Data /E /H /I /Y /K
Every xcopy option
Based on Microsoft's xcopy reference and xcopy /? on Windows 11. Open a section for the details.
Subfolders, folder structure, which files by attribute or date, and what to leave out.
| Option | What it does | Example |
|---|---|---|
| /S | Copies subfolders, skipping empty ones. Without /S or /E xcopy copies only the files directly in the source folder. /S goes through the whole tree but leaves out folders that would end up empty. | xcopy C:\Data D:\Data /S /I |
Note: /E does the same and also creates empty folders, so /S /E is the same as /E. | ||
| /E | Copies subfolders, including empty ones. The usual choice for copying a folder tree: every subfolder is recreated at the destination, even empty ones. On its own it already includes /S. | xcopy C:\Data D:\Data /E /I |
Note: Combine with /T to create only the folder structure, empty folders included. Includes /S. | ||
| /T | Creates the folder structure without copying any files. Recreates the folder tree at the destination and copies no files. On its own it skips empty folders; add /E to include them. | xcopy C:\Projects D:\Template /T /E /I |
| /A | Copies only files with the archive attribute set, and leaves it set. Picks the files Windows has marked as changed since the archive attribute was last cleared, without clearing it, so the next run selects them again. | xcopy C:\Data D:\Changes /S /A |
Note: /M does the same but clears the attribute; use one or the other. | ||
| /M | Copies only files with the archive attribute set, then clears it. Copies the files marked as changed and clears their archive attribute, so the next run copies only what changed after this one: a simple incremental backup. | xcopy C:\Data D:\Incremental /S /M |
Note: Changes the source files' attributes, which can upset backup software that relies on the archive bit. | ||
| /D[:MM-DD-YYYY] | Copies only files changed on or after a date, or newer than the destination's copy. With a date (month-day-year), copies files modified on or after that day. Without one, copies only files whose source copy is newer than the destination's, which makes it an "update" switch. | xcopy C:\Data D:\Data /D /E /I /Y |
| /U | Copies only files that already exist in the destination. Refreshes files that are already there and adds nothing new. Combine with /D to refresh only the ones that changed. | xcopy C:\Data D:\Data /U /D /Y |
| /H | Also copies hidden and system files. xcopy skips files with the hidden or system attribute unless you add /H. Needed for complete copies of profiles and application folders. | xcopy C:\Users\Admin D:\Profile /E /H /I |
| /EXCLUDE:file[+file]... | Skips files whose path contains a string listed in a text file. Each file named here is a text file with one search string per line. Any file whose full path contains one of the strings is skipped: \obj\ skips everything in folders named obj, .tmp skips files with .tmp anywhere in the name. These are plain text matches, not wildcards. | xcopy C:\Src D:\Src /E /I /EXCLUDE:C:\Scripts\skip.txt |
Note: xcopy can't read a list file whose path contains a space, even in quotes; keep these files in a path without spaces. | ||
| /B | Copies symbolic links themselves instead of the files they point to. Without /B xcopy follows a symbolic link and copies the target's contents. With it, the link is recreated at the destination. | xcopy C:\Tools D:\Tools /E /B /I |
Available since Windows Vista. | ||
Overwriting, attributes, permissions, network and large-file options.
| Option | What it does | Example |
|---|---|---|
| /I | Treats a destination that doesn't exist yet as a folder. When the source is a folder or a wildcard and the destination doesn't exist, xcopy normally stops to ask whether the destination is a file or a directory. /I answers "directory" in advance, which scripts need. | xcopy C:\Data D:\NewFolder /E /I |
| /-I | Treats a destination that doesn't exist yet as a file name (single file only). The opposite of /I for copying one file: the destination is taken as the new file's name. Listed by xcopy /? on current Windows 11 builds. | xcopy C:\Data\report.docx D:\Archive\report-2026.docx /-I |
Note: Use one of /I and /-I. | ||
| /Y | Overwrites existing files without asking. xcopy normally asks before replacing each file that already exists at the destination. /Y skips the question, which unattended scripts need. | xcopy C:\Data D:\Data /E /I /Y |
Note: /Y can also be set for every copy, move and xcopy in the COPYCMD environment variable; /-Y overrides it. | ||
| /-Y | Asks before overwriting existing files. Forces the overwrite question even when COPYCMD contains /Y. | xcopy C:\Data D:\Data /E /I /-Y |
| /R | Overwrites read-only files at the destination. Without /R, xcopy stops at destination files marked read-only. With it, they're replaced like any other file. | xcopy C:\Data D:\Data /E /I /Y /R |
| /K | Keeps the read-only attribute on the copies. By default xcopy clears the read-only attribute on the files it writes. /K keeps the source's attributes as they are. | xcopy C:\Data D:\Data /E /I /K |
| /O | Copies the owner and permissions (DACL) of each file. Copies NTFS ownership and access control entries along with the data, so the copies have the same permissions as the originals. | xcopy D:\Shares E:\Shares /E /I /H /K /O |
Note: Setting the owner normally needs an elevated prompt (Run as administrator). | ||
| /X | Copies auditing settings (SACL) as well as owner and permissions. Everything /O copies, plus the file's audit entries. Includes /O. | xcopy D:\Shares E:\Shares /E /I /H /K /X |
Note: Copying audit settings needs the Manage auditing and security log right, usually an elevated prompt. Includes /O. | ||
| /N | Copies using the 8.3 short names. Writes files and folders under their generated short names (PROGRA~1). Only for destinations that need old FAT-style names. | xcopy C:\Data A:\ /S /N |
| /G | Lets encrypted files be copied to a destination that can't keep them encrypted. Copying EFS-encrypted files to a drive without EFS support (FAT, many network shares) fails unless you add /G, which writes them decrypted. | xcopy C:\Secure E:\Secure /E /I /G |
| /Z | Copies over the network in restartable mode. If the connection drops in the middle of a file, the copy continues from where it stopped once the connection is back, and progress is shown per file. | xcopy \\fs01\iso D:\iso /Z /I |
| /J | Copies without buffering (for very large files). Uses unbuffered I/O, which is faster for very large files such as virtual disks and images and keeps them out of the file cache. | xcopy D:\VMs\server.vhdx E:\VMs\ /J |
Available since Windows Server 2008 R2. | ||
| /V | Checks each new file after it's written. Verifies every copied file against the source. Microsoft's reference says identical, xcopy /? says it checks the size. | xcopy C:\Data D:\Data /E /I /V |
| /C | Keeps going after errors. Without /C, xcopy stops at the first file it can't copy. With it, it reports the error and carries on. | xcopy C:\Data D:\Data /E /I /C |
| /COMPRESS | Asks for network compression during the transfer, where available. Requests SMB compression when copying to or from a server that supports it, which helps over slow links. | xcopy C:\Data \\fs01\Data /E /I /COMPRESS |
| /SPARSE | Keeps sparse files sparse. Copies sparse files (with large empty regions) as sparse files instead of writing every zero. | xcopy D:\Data E:\Data /E /I /SPARSE |
| /-SPARSE | Doesn't keep sparse files sparse. Writes sparse files out in full. Wins over /SPARSE when both are given. | xcopy D:\Data E:\Data /E /I /-SPARSE |
| /NOCLONE | Doesn't try block cloning. On volumes that support it (ReFS, Dev Drive) copies can be made by cloning blocks instead of writing data. /NOCLONE turns that optimization off. | xcopy D:\Data D:\Copy /E /I /NOCLONE |
Confirmation prompts, what xcopy prints, and dry runs.
| Option | What it does | Example |
|---|---|---|
| /L | Lists the files that would be copied, without copying anything. A dry run: xcopy prints the files it would copy and the count, and creates nothing at the destination. | xcopy C:\Data D:\Data /E /I /L |
| /F | Shows the full source and destination name of each file. Prints both paths for every file instead of only the source name. | xcopy C:\Data D:\Data /E /I /F |
| /Q | Doesn't list files while copying. Prints only the final count, which keeps logs short. | xcopy C:\Data D:\Data /E /I /Q |
| /P | Asks before creating each destination file. Prompts Yes/No for every file. Useful for picking files by hand, useless in scripts. | xcopy C:\Data D:\Data /P |
| /W | Waits for a key press before starting. Prints "Press any key to begin copying file(s)" first, for example to give time to insert a disk. | xcopy C:\Data A:\ /W |