ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0.1 months ago (distributed domain, exempt) |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy |
| Last Crawled | 2026-04-15 20:19:36 (3 days ago) |
| First Indexed | 2022-09-18 10:05:23 (3 years ago) |
| HTTP Status Code | 200 |
| Meta Title | xcopy | Microsoft Learn |
| Meta Description | Reference article for xcopy, which copies files and directories, including subdirectories. |
| Meta Canonical | null |
| Boilerpipe Text | Copies files and directories, including subdirectories.
For examples of how to use this command, see
Examples
.
xcopy <Source> [<Destination>] [/w] [/p] [/c] [/v] [/q] [/f] [/l] [/g] [/d [:MM-DD-YYYY]] [/u] [/i] [/s [/e]] [/t] [/k] [/r] [/h] [{/a | /m}] [/n] [/o] [/x] [/exclude:FileName1[+[FileName2]][+[FileName3]]] [{/y | /-y}] [/z] [/b] [/j] [/compress]
Parameter
Description
<Source>
Required. Specifies the location and names of the files you want to copy. This parameter must include either a drive or a path.
[<Destination>]
Specifies the destination of the files you want to copy. This parameter can include a drive letter and colon, a directory name, a file name, or a combination of these.
/w
Displays the following message and waits for your response before starting to copy files:
Press any key to begin copying file(s)
/p
Prompts you to confirm whether you want to create each destination file.
/c
Ignores errors.
/v
Verifies each file as it is written to the destination file to make sure that the destination files are identical to the source files.
/q
Suppresses the display of
xcopy
messages.
/f
Displays source and destination file names while copying.
/l
Generates a list of files that are to be copied, but doesn't actively copy the files.
/g
Creates decrypted
destination
files when the destination doesn't support encryption.
/d [:MM-DD-YYYY]
Copies source files changed on or after the specified date only. If you don't include a
MM-DD-YYYY
value,
xcopy
copies all
source
files that are newer than existing
destination
files. This command-line option allows you to update files that have changed.
/u
Copies files from
source
that exist on
destination
only.
/i
If
source
is a directory or contains wildcards and
destination
doesn't exist,
xcopy
assumes
destination
specifies a directory name and creates a new directory. 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.
/s
Copies directories and subdirectories, unless they're empty. If you omit
/s
,
xcopy
works within a single directory.
/e
Copies all subdirectories, even if they're empty. Use
/e
with the
/s
and
/t
command-line options.
/t
Copies the subdirectory structure (that is, the tree) only, not files. To copy empty directories, you must include the
/e
command-line option.
/k
Copies files and retains the read-only attribute on
destination
files if present on the
source
files. By default,
xcopy
removes the read-only attribute.
/r
Copies read-only files.
/h
Copies files with hidden and system file attributes. By default,
xcopy
doesn't copy hidden or system files
/a
Copies only
source
files that have their archive file attributes set.
/a
doesn't modify the archive file attribute of the source file. For information about how to set the archive file attribute by using
attrib
, see
Related links
.
/m
Copies
source
files that have their archive file attributes set. Unlike
/a
,
/m
turns off archive file attributes in the files that are specified in the source. For information about how to set the archive file attribute by using
attrib
, see
Related links
.
/n
Creates copies by using the NTFS short file or directory names.
/n
is required when you copy files or directories from an NTFS volume to a FAT volume or when the FAT file system naming convention (that is, 8.3 characters) is required on the
destination
file system. The
destination
file system can be FAT or NTFS.
/o
Copies file ownership and discretionary access control list (DACL) information.
/x
Copies file audit settings and system access control list (SACL) information (implies
/o
).
/exclude:FileName1[+[FileName2]][+[FileName3]( )]
Specifies a list of files. At least one file must be specified. Each file contains search strings with each string on a separate line in the file. When any of the strings match any part of the absolute path of the file to be copied, that file is excluded from being copied. For example, specifying the string
obj
will exclude all files underneath the directory
obj
or all files with the
.obj
extension.
/y
Suppresses prompting to confirm that you want to overwrite an existing destination file.
/-y
Prompts to confirm that you want to overwrite an existing destination file.
/z
Copies over a network in restartable mode.
/b
Copies the symbolic link instead of the files. This parameter was introduced in Windows Vista®.
/j
Copies files without buffering. Recommended for very large files. This parameter was added in Windows Server 2008 R2.
/compress
Request network compression during file transfer where applicable.
/[
-
]sparse
Enables or disables retaining the sparse state of files during copy process. If both parameters are specified,
/-sparse
overrides
/sparse
.
/noclone
Doesn't attempt block cloning as an optimization.
/?
Displays help at the command prompt.
Using
/z
If you lose your connection during the copy phase (for example, if the server going offline severs the connection), it resumes after you reestablish the connection.
/z
also displays the percentage of the copy operation completed for each file.
Using
/y
in the COPYCMD environment variable.
You can use
/y
in the COPYCMD environment variable. You can override this command by using
/-y
on the command line. By default, you're prompted to overwrite.
Copying encrypted files
Copying encrypted files to a volume that doesn't support EFS results in an error. Decrypt the files first or copy the files to a volume that does support EFS.
Appending files
To append files, specify a single file for destination, but multiple files for source (that is, by using wildcards or file1+file2+file3 format).
Default value for
destination
If you omit
destination
, the
xcopy
command copies the files to the current directory.
Specifying whether
destination
is a file or directory
If
destination
doesn't contain an existing directory and doesn't end with a backslash (), the following message appears:
Does <Destination> specify a file name or directory name on the target(F = file, D = directory)?
Press F if you want the file or files to be copied to a file. Press D if you want the file or files to be copied to a directory.
You can suppress this message by using the
/i
command-line option, which causes
xcopy
to assume that the destination is a directory if the source is more than one file or a directory.
Using the
xcopy
command to set archive attribute for
destination
files
The
xcopy
command creates files with the archive attribute set, whether or not this attribute was set in the source file. For more information about file attributes and
attrib
, see
Related links
.
Comparing
xcopy
and
diskcopy
If you have a disk that contains files in subdirectories and you want to copy it to a disk that has a different format, use the
xcopy
command instead of
diskcopy
. Because the
diskcopy
command copies disks track by track, your source and destination disks must have the same format. The
xcopy
command doesn't have this requirement. Use
xcopy
unless you need a complete disk image copy.
Insufficient memory error
An "insufficient memory" error may occur if running
xcopy
to copy a file or folder whose filename path is greater than 255 characters.
Exit codes for
xcopy
To process exit codes returned by
xcopy
, use the
ErrorLevel
parameter on the
if
command line in a batch program. For an example of a batch program that processes exit codes using
if
, see
Related links
. The following table lists each exit code and a description.
Exit code
Description
0
Files were copied without error.
1
No files were found to copy.
2
The user pressed CTRL+C to terminate
xcopy
.
4
Initialization error occurred. There isn't enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line.
5
Disk write error occurred.
1.
To copy all the files and subdirectories (including any empty subdirectories) from drive A to drive B, type:
xcopy a: b: /s /e
2.
To include any system or hidden files in the previous example, add the
/h
command-line option as follows:
xcopy a: b: /s /e /h
3.
To update files in the \Reports directory with the files in the \Rawdata directory that have changed since December 29, 1993, type:
xcopy \rawdata \reports /d:12-29-1993
4.
To update all the files that exist in \Reports in the previous example, regardless of date, type:
xcopy \rawdata \reports /u
5.
To obtain a list of the files to be copied by the previous command (that is, without actually copying the files), type:
xcopy \rawdata \reports /d:12-29-1993 /l > xcopy.out
The file xcopy.out lists every file that is to be copied.
6.
To copy the \Customer directory and all subdirectories to the directory \\Public\Address on network drive H:, retain the read-only attribute, and be prompted when a new file is created on H:, type:
xcopy \customer h:\public\address /s /e /k /p
7.
To issue the previous command, ensure that
xcopy
creates the \Address directory if it doesn't exist, and suppress the message that appears when you create a new directory, add the
/i
command-line option as follows:
xcopy \customer h:\public\address /s /e /k /p /i
8.
You can create a batch program to perform
xcopy
operations and use the batch
if
command to process the exit code if an error occurs. For example, the following batch program uses replaceable parameters for the
xcopy
source and destination parameters:
@echo off
rem COPYIT.BAT transfers all files in all subdirectories of
rem the source drive or directory (%1) to the destination
rem drive or directory (%2)
xcopy %1 %2 /s /e
if errorlevel 4 goto lowmemory
if errorlevel 2 goto abort
if errorlevel 0 goto exit
:lowmemory
echo Insufficient memory to copy files or
echo invalid drive or command-line syntax.
goto exit
:abort
echo You pressed CTRL+C to end the copy operation.
goto exit
:exit
To use the preceding batch program to copy all files in the C:\Prgmcode directory and its subdirectories to drive B, type:
copyit c:\prgmcode b:
The command interpreter substitutes
C:\Prgmcode
for
%1
and
B:
for
%2
, then uses
xcopy
with the
/e
and
/s
command-line options. If
xcopy
encounters an error, the batch program reads the exit code and goes to the label indicated in the appropriate
IF ERRORLEVEL
statement, then displays the appropriate message and exits from the batch program.
9.
This example copies all the non-empty directories, plus files with the associated file extension after the asterisk symbol.
xcopy .\toc*.yml ..\..\Copy-To\ /S /Y
rem Output example.
rem .\d1\toc.yml
rem .\d1\d12\toc.yml
rem .\d2\toc.yml
rem 3 File(s) copied
In the preceding example, this particular source parameter value
.\toc*.yml
copies the same 3 files even if its two path characters
.\
were removed. However, no files would be copied if the asterisk wildcard was removed from the source parameter, making it just
.\toc.yml
.
Copy
Move
Dir
Attrib
Diskcopy
If
Command-Line Syntax Key |
| Markdown | [Skip to main content](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#main) [Skip to Ask Learn chat experience](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy)
## Microsoft Build 2026
June 2-3, 2026
Go deep on real code and real systems in San Francisco and online
[Learn more](https://aka.ms/MSBuild_FY26_BN_MSLearn_Hero)
Dismiss alert
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
[Download Microsoft Edge](https://go.microsoft.com/fwlink/p/?LinkID=2092881%20) [More info about Internet Explorer and Microsoft Edge](https://learn.microsoft.com/en-us/lifecycle/faq/internet-explorer-microsoft-edge)
[Learn](https://learn.microsoft.com/en-us/)
[Sign in](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy)
![]()
![]()
- [Profile](https://learn.microsoft.com/en-us/users/me/activity/)
- [Analytics](https://learn.microsoft.com/en-us/users/me/analytics/)
- [Settings](https://learn.microsoft.com/en-us/users/me/settings/)
[Sign out](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy)
[Learn](https://learn.microsoft.com/en-us/)
- Documentation
- [All product documentation](https://learn.microsoft.com/en-us/docs/)
- [Azure documentation](https://learn.microsoft.com/en-us/azure/?product=popular)
- [Dynamics 365 documentation](https://learn.microsoft.com/en-us/dynamics365/)
- [Microsoft Copilot documentation](https://learn.microsoft.com/en-us/copilot/)
- [Microsoft 365 documentation](https://learn.microsoft.com/en-us/microsoft-365/)
- [Power Platform documentation](https://learn.microsoft.com/en-us/power-platform/)
- [Code samples](https://learn.microsoft.com/en-us/samples/)
- [Troubleshooting documentation](https://learn.microsoft.com/en-us/troubleshoot/)
Free to join. Request to attend.
[Microsoft AI Tour](https://aitour.microsoft.com/?wt.mc_id=itour26_learnmarketingspot_wwl)
Take your business to the AI frontier.
- Training & Labs
- [All training](https://learn.microsoft.com/en-us/training/)
- [Azure training](https://learn.microsoft.com/en-us/training/browse/?products=azure)
- [Dynamics 365 training](https://learn.microsoft.com/en-us/training/browse/?products=dynamics-365)
- [Microsoft Copilot training](https://learn.microsoft.com/en-us/training/browse/?products=ms-copilot)
- [Microsoft 365 training](https://learn.microsoft.com/en-us/training/browse/?products=m365)
- [Microsoft Power Platform training](https://learn.microsoft.com/en-us/training/browse/?products=power-platform)
- [Labs](https://learn.microsoft.com/en-us/labs/)
- [Credentials](https://learn.microsoft.com/en-us/credentials/)
- [Career paths](https://learn.microsoft.com/en-us/training/career-paths/)
Free to join. Request to attend.
[Microsoft AI Tour](https://aitour.microsoft.com/?wt.mc_id=itour26_learnmarketingspot_wwl)
Take your business to the AI frontier.
- Q\&A
- [Ask a question](https://learn.microsoft.com/en-us/answers/questions/ask/)
- [Azure questions](https://learn.microsoft.com/en-us/answers/tags/133/azure/)
- [Windows questions](https://learn.microsoft.com/en-us/answers/tags/60/windows/)
- [Microsoft 365 questions](https://learn.microsoft.com/en-us/answers/tags/9/m365/)
- [Microsoft Outlook questions](https://learn.microsoft.com/en-us/answers/tags/131/office-outlook/)
- [Microsoft Teams questions](https://learn.microsoft.com/en-us/answers/tags/108/office-teams/)
- [Popular tags](https://learn.microsoft.com/en-us/answers/tags/)
- [All questions](https://learn.microsoft.com/en-us/answers/questions/)
Free to join. Request to attend.
[Microsoft AI Tour](https://aitour.microsoft.com/?wt.mc_id=itour26_learnmarketingspot_wwl)
Take your business to the AI frontier.
- Topics
- [Artificial intelligence](https://learn.microsoft.com/en-us/ai/)
Learning hub to build AI skills
- [Compliance](https://learn.microsoft.com/en-us/compliance/)
Compliance resources you need to get started with your business
- [DevOps](https://learn.microsoft.com/en-us/devops/)
DevOps practices, Git version control and Agile methods
- [Learn for Organizations](https://learn.microsoft.com/en-us/training/organizations/)
Curated offerings from Microsoft to boost your team’s technical skills
- [Platform engineering](https://learn.microsoft.com/en-us/platform-engineering/)
Tools from Microsoft and others to build personalized developer experiences
- [Security](https://learn.microsoft.com/en-us/security/)
Guidance to help you tackle security challenges
- [Assessments](https://learn.microsoft.com/en-us/assessments/)
Interactive guidance with custom recommendations
- [Student hub](https://learn.microsoft.com/en-us/training/student-hub/)
Self-paced and interactive training for students
- [Educator center](https://learn.microsoft.com/en-us/training/educator-center/)
Resources for educators to bring technical innovation in their classroom
Free to join. Request to attend.
[Microsoft AI Tour](https://aitour.microsoft.com/?wt.mc_id=itour26_learnmarketingspot_wwl)
Take your business to the AI frontier.
[Sign in](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy)
![]()
![]()
- [Profile](https://learn.microsoft.com/en-us/users/me/activity/)
- [Analytics](https://learn.microsoft.com/en-us/users/me/analytics/)
- [Settings](https://learn.microsoft.com/en-us/users/me/settings/)
[Sign out](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy)
[Windows Server](https://learn.microsoft.com/en-us/windows-server/)
- [Get started](https://learn.microsoft.com/en-us/windows-server/get-started/get-started-with-windows-server)
- Learn Windows Server
- [Browse all training](https://learn.microsoft.com/en-us/training/browse/?products=windows-server)
- [Instructor-led courses](https://learn.microsoft.com/en-us/training/browse/?resource_type=course&products=windows-server)
- [Earn credentials](https://learn.microsoft.com/en-us/credentials/browse/?products=windows-server)
- [Troubleshooting](https://learn.microsoft.com/en-us/troubleshoot/windows-server/welcome-windows-server)
- [Previous versions documentation](https://learn.microsoft.com/en-us/previous-versions/windows/)
- Resources
- [Extended Security Updates](https://learn.microsoft.com/en-us/windows-server/extended-security-updates)
- [Windows Server Tech Community](https://techcommunity.microsoft.com/t5/windows-server/ct-p/Windows-Server)
- [Windows Server Blog](https://www.microsoft.com/windows-server/blog/)
- [Windows Server datasheet](https://go.microsoft.com/fwlink/?linkid=2299415)
- More
- [Get started](https://learn.microsoft.com/en-us/windows-server/get-started/get-started-with-windows-server)
- Learn Windows Server
- [Browse all training](https://learn.microsoft.com/en-us/training/browse/?products=windows-server)
- [Instructor-led courses](https://learn.microsoft.com/en-us/training/browse/?resource_type=course&products=windows-server)
- [Earn credentials](https://learn.microsoft.com/en-us/credentials/browse/?products=windows-server)
- [Troubleshooting](https://learn.microsoft.com/en-us/troubleshoot/windows-server/welcome-windows-server)
- [Previous versions documentation](https://learn.microsoft.com/en-us/previous-versions/windows/)
- Resources
- [Extended Security Updates](https://learn.microsoft.com/en-us/windows-server/extended-security-updates)
- [Windows Server Tech Community](https://techcommunity.microsoft.com/t5/windows-server/ct-p/Windows-Server)
- [Windows Server Blog](https://www.microsoft.com/windows-server/blog/)
- [Windows Server datasheet](https://go.microsoft.com/fwlink/?linkid=2299415)
[Get Windows Server](https://www.microsoft.com/windows-server) [Free trial](https://www.microsoft.com/evalcenter/evaluate-windows-server-2025?icid=msft_learn)
- [Windows Commands](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands)
- [Command-Line Syntax Key](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/command-line-syntax-key)
- Reference
- Commands by Server Role
- [adprep](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/adprep)
- [append](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/append)
- [arp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/arp)
- [assoc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/assoc)
- [at](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/at)
- [atmadm](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/atmadm)
- [attrib](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/attrib)
- auditpol
- [autochk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/autochk)
- [autoconv](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/autoconv)
- [autofmt](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/autofmt)
- [bcdboot](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bcdboot)
- [bcdedit](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/bcdedit)
- bdehdcfg
- bitsadmin
- bootcfg
- [break](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/break)
- [cacls](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cacls)
- [call](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/call)
- [cd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cd)
- [certreq](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/certreq_1)
- [certutil](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/certutil)
- change
- [chcp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chcp)
- [chdir](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chdir)
- [chglogon](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chglogon)
- [chgport](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chgport)
- [chgusr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chgusr)
- [chkdsk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chkdsk)
- [chkntfs](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chkntfs)
- [choice](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/choice)
- [cipher](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cipher)
- [cleanmgr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cleanmgr)
- [clip](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/clip)
- [cls](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cls)
- [cmd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd)
- [cmdkey](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmdkey)
- [cmstp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmstp)
- [color](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/color)
- [comp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/comp)
- [compact](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/compact)
- [copy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/copy)
- [cscript](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cscript)
- [date](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/date)
- [dcdiag](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dcdiag)
- [dcgpofix](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dcgpofix)
- [dcpromo](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dcpromo)
- [defrag](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/defrag)
- [del](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/del)
- dfsdiag
- [dfsrmig](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dfsrmig)
- [dfsutil](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dfsutil)
- [diantz](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diantz)
- [dir](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dir)
- [diskcomp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskcomp)
- [diskcopy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskcopy)
- [diskpart](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskpart)
- diskpart scripts and examples
- [diskperf](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskperf)
- [diskraid](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskraid)
- diskshadow
- [dispdiag](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dispdiag)
- [dnscmd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dnscmd)
- [doskey](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/doskey)
- [driverquery](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/driverquery)
- [dtrace](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dtrace)
- [echo](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/echo)
- [edit](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/edit)
- [endlocal](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/endlocal)
- [erase](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/erase)
- [eventcreate](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/eventcreate)
- [evntcmd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/evntcmd)
- [expand](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/expand)
- [extract](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/extract)
- [fc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fc)
- [find](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/find)
- [findstr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/findstr)
- [finger](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/finger)
- [flattemp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/flattemp)
- [fondue](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fondue)
- [for](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/for)
- [forfiles](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/forfiles)
- [freedisk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/freedisk)
- fsutil
- ftp
- [ftype](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftype)
- [fveupdate](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/fveupdate)
- [getmac](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/getmac)
- [gettype](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/gettype)
- [goto](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/goto)
- [gpfixup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/gpfixup)
- [gpresult](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/gpresult)
- [gpupdate](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/gpupdate)
- [graftabl](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/graftabl)
- [help](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/help)
- [helpctr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/helpctr)
- [hostname](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/hostname)
- [icacls](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/icacls)
- [if](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/if)
- [ipconfig](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ipconfig)
- [ipxroute](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ipxroute)
- [irftp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/irftp)
- [jetpack](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/jetpack)
- [klist](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/klist)
- ksetup
- [ktmutil](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ktmutil)
- [ktpass](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ktpass)
- [label](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/label)
- [lodctr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/lodctr)
- logman
- [logoff](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logoff)
- [lpq](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/lpq)
- [lpr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/lpr)
- [macfile](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/macfile)
- [makecab](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/makecab)
- manage bde
- [mapadmin](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mapadmin)
- [md](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/md)
- [mkdir](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mkdir)
- [mklink](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mklink)
- [mmc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mmc)
- [mode](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mode)
- [more](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/more)
- [mount](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mount)
- [mountvol](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mountvol)
- [move](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/move)
- [mqbkup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mqbkup)
- [mqsvc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mqsvc)
- [mqtgsvc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mqtgsvc)
- [msdt](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msdt)
- [msg](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msg)
- [msiexec](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec)
- [msinfo32](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msinfo32)
- [mstsc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mstsc)
- [nbtstat](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nbtstat)
- [net print](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/net-print)
- [net user](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/net-user)
- [netcfg](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netcfg)
- netdom
- network shell (netsh)
- [netstat](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netstat)
- [nfsadmin](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nfsadmin)
- [nfsshare](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nfsshare)
- [nfsstat](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nfsstat)
- [nlbmgr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nlbmgr)
- nslookup
- [ntbackup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ntbackup)
- [ntcmdprompt](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ntcmdprompt)
- [ntfrsutl](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ntfrsutl)
- [openfiles](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/openfiles)
- [pagefileconfig](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pagefileconfig)
- [path](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/path)
- [pathping](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pathping)
- [pause](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pause)
- [pbadmin](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pbadmin)
- [pentnt](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pentnt)
- [perfmon](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/perfmon)
- [ping](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ping)
- pktmon
- [pnpunattend](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pnpunattend)
- [pnputil](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pnputil)
- [popd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/popd)
- [powershell](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/powershell)
- [powershell ise](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/powershell_ise)
- [print](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/print)
- [prncnfg](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/prncnfg)
- [prndrvr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/prndrvr)
- [prnjobs](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/prnjobs)
- [prnmngr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/prnmngr)
- [prnport](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/prnport)
- [prnqctl](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/prnqctl)
- [prompt](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/prompt)
- [pubprn](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pubprn)
- [pushd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pushd)
- [pushprinterconnections](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pushprinterconnections)
- [pwlauncher](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/pwlauncher)
- [qappsrv](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/qappsrv)
- [qprocess](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/qprocess)
- query
- [quser](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/quser)
- [qwinsta](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/qwinsta)
- [rd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rd)
- [rdpsign](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rdpsign)
- [recover disk group](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/recover_1)
- refsutil
- reg
- [regini](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/regini)
- [regsvr32](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/regsvr32)
- [relog](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/relog)
- [ren](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ren)
- [rename](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rename)
- [repair bde](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/repair-bde)
- [replace](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/replace)
- [rexec](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rexec)
- [risetup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/risetup)
- [rmdir](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rmdir)
- [robocopy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy)
- [route ws2008](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/route_ws2008)
- [rpcinfo](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rpcinfo)
- [rpcping](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rpcping)
- [rsh](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rsh)
- [rundll32](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rundll32)
- [rundll32 printui](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rundll32-printui)
- [rwinsta](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/rwinsta)
- [sc config](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sc-config)
- [sc create](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sc-create)
- [sc delete](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sc-delete)
- [sc query](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sc-query)
- schtasks
- scwcmd
- secedit
- [serverceipoptin](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/serverceipoptin)
- [servermanagercmd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/servermanagercmd)
- [serverweroptin](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/serverweroptin)
- [Services for Network File System (NFS) command reference](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/services-for-network-file-system-command-reference)
- [set environmental variables](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/set_1)
- [setlocal](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/setlocal)
- [setspn](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/setspn)
- [setx](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/setx)
- [sfc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sfc)
- [shadow](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/shadow)
- [shift](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/shift)
- [showmount](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/showmount)
- [shutdown](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/shutdown)
- [simulate restore](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/simulate-restore)
- [sort](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sort)
- [start](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/start)
- [subst](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/subst)
- [sxstrace](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sxstrace)
- [sysmon](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sysmon)
- [sysocmgr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sysocmgr)
- [systeminfo](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/systeminfo)
- [takeown](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/takeown)
- tapicfg
- [taskkill](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill)
- [tasklist](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tasklist)
- [tcmsetup](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tcmsetup)
- telnet
- [tftp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tftp)
- [time](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/time)
- [timeout](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/timeout)
- [title](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/title)
- [tlntadmn](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tlntadmn)
- [tpmtool](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tpmtool)
- [tpmvscmgr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tpmvscmgr)
- [tracerpt](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tracerpt)
- [tracert](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tracert)
- [tree](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tree)
- [tscon](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tscon)
- [tsdiscon](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tsdiscon)
- [tsecimp](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tsecimp)
- [tskill](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tskill)
- [tsprof](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tsprof)
- [type](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/type)
- [typeperf](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/typeperf)
- [tzutil](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tzutil)
- [unlodctr](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/unlodctr)
- [ver](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ver)
- [verifier](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/verifier)
- [verify](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/verify)
- [vol](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/vol)
- vssadmin
- [waitfor](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/waitfor)
- wbadmin
- wdsutil
- [wecutil](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wecutil)
- [wevtutil](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wevtutil)
- [where](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/where)
- [whoami](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/whoami)
- [winnt](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/winnt)
- [winnt32](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/winnt32)
- [winrs](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/winrs)
- [winsat mem](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/winsat-mem)
- [winsat mfmedia](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/winsat-mfmedia)
- [wmic](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wmic)
- [wscript](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wscript)
- [xcopy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy)
Download PDF
Table of contents
Exit editor mode
1. [Learn](https://learn.microsoft.com/en-us/)
2. [Windows Server](https://learn.microsoft.com/en-us/windows-server/)
3. [Windows commands](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands/)
1. [Learn](https://learn.microsoft.com/en-us/)
2. [Windows Server](https://learn.microsoft.com/en-us/windows-server/)
3. [Windows commands](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands/)
Ask Learn
Ask Learn
Focus mode
Table of contents
[Read in English](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy)
Add to Collections
Add to plan
[Edit](https://github.com/MicrosoftDocs/windowsserverdocs/blob/main/WindowsServerDocs/administration/windows-commands/xcopy.md)
***
#### Share via
[Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fwindows-server%2Fadministration%2Fwindows-commands%2Fxcopy%3FWT.mc_id%3Dfacebook) [x.com](https://twitter.com/intent/tweet?original_referer=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fwindows-server%2Fadministration%2Fwindows-commands%2Fxcopy%3FWT.mc_id%3Dtwitter&tw_p=tweetbutton&url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fwindows-server%2Fadministration%2Fwindows-commands%2Fxcopy%3FWT.mc_id%3Dtwitter) [LinkedIn](https://www.linkedin.com/feed/?shareActive=true&text=%0A%0D%0Ahttps%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fwindows-server%2Fadministration%2Fwindows-commands%2Fxcopy%3FWT.mc_id%3Dlinkedin) [Email](mailto:?subject=%5BShared%20Article%5D%20xcopy%20%7C%20Microsoft%20Learn&body=%0A%0D%0Ahttps%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fwindows-server%2Fadministration%2Fwindows-commands%2Fxcopy%3FWT.mc_id%3Demail)
***
Copy Markdown
Print
***
Note
Access to this page requires authorization. You can try [signing in](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy) or [changing directories]().
Access to this page requires authorization. You can try [changing directories]().
# xcopy
- Applies to: ✅ [Windows Server 2025](https://learn.microsoft.com/windows-server/get-started/windows-server-release-info), ✅ [Windows Server 2022](https://learn.microsoft.com/windows-server/get-started/windows-server-release-info), ✅ [Windows Server 2019](https://learn.microsoft.com/windows-server/get-started/windows-server-release-info), ✅ [Windows Server 2016](https://learn.microsoft.com/windows-server/get-started/windows-server-release-info), ✅ [Windows 11](https://learn.microsoft.com/windows/release-health/supported-versions-windows-client), ✅ [Windows 10](https://learn.microsoft.com/windows/release-health/supported-versions-windows-client), ✅ [Azure Local 2311.2 and later](https://learn.microsoft.com/azure/azure-local/release-information-23h2)
Feedback
Summarize this article for me
## In this article
1. [Syntax](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#syntax)
2. [Remarks](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#remarks)
3. [Examples](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#examples)
4. [Related links](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#related-links)
Copies files and directories, including subdirectories.
For examples of how to use this command, see [Examples](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#examples).
## Syntax
Copy
```
xcopy <Source> [<Destination>] [/w] [/p] [/c] [/v] [/q] [/f] [/l] [/g] [/d [:MM-DD-YYYY]] [/u] [/i] [/s [/e]] [/t] [/k] [/r] [/h] [{/a | /m}] [/n] [/o] [/x] [/exclude:FileName1[+[FileName2]][+[FileName3]]] [{/y | /-y}] [/z] [/b] [/j] [/compress]
```
### Parameters
Expand table
| Parameter | Description |
|---|---|
| \<Source\> | Required. Specifies the location and names of the files you want to copy. This parameter must include either a drive or a path. |
| \[\<Destination\>\] | Specifies the destination of the files you want to copy. This parameter can include a drive letter and colon, a directory name, a file name, or a combination of these. |
| /w | Displays the following message and waits for your response before starting to copy files: **Press any key to begin copying file(s)** |
| /p | Prompts you to confirm whether you want to create each destination file. |
| /c | Ignores errors. |
| /v | Verifies each file as it is written to the destination file to make sure that the destination files are identical to the source files. |
| /q | Suppresses the display of `xcopy` messages. |
| /f | Displays source and destination file names while copying. |
| /l | Generates a list of files that are to be copied, but doesn't actively copy the files. |
| /g | Creates decrypted *destination* files when the destination doesn't support encryption. |
| /d \[:MM-DD-YYYY\] | Copies source files changed on or after the specified date only. If you don't include a *MM-DD-YYYY* value, `xcopy` copies all *source* files that are newer than existing *destination* files. This command-line option allows you to update files that have changed. |
| /u | Copies files from *source* that exist on *destination* only. |
| /i | If *source* is a directory or contains wildcards and *destination* doesn't exist, `xcopy` assumes *destination* specifies a directory name and creates a new directory. 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. |
| /s | Copies directories and subdirectories, unless they're empty. If you omit **/s**, `xcopy` works within a single directory. |
| /e | Copies all subdirectories, even if they're empty. Use **/e** with the **/s** and **/t** command-line options. |
| /t | Copies the subdirectory structure (that is, the tree) only, not files. To copy empty directories, you must include the **/e** command-line option. |
| /k | Copies files and retains the read-only attribute on *destination* files if present on the *source* files. By default, `xcopy` removes the read-only attribute. |
| /r | Copies read-only files. |
| /h | Copies files with hidden and system file attributes. By default, `xcopy` doesn't copy hidden or system files |
| /a | Copies only *source* files that have their archive file attributes set. **/a** doesn't modify the archive file attribute of the source file. For information about how to set the archive file attribute by using **attrib**, see [Related links](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#related-links). |
| /m | Copies *source* files that have their archive file attributes set. Unlike **/a**, **/m** turns off archive file attributes in the files that are specified in the source. For information about how to set the archive file attribute by using **attrib**, see [Related links](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#related-links). |
| /n | Creates copies by using the NTFS short file or directory names. **/n** is required when you copy files or directories from an NTFS volume to a FAT volume or when the FAT file system naming convention (that is, 8.3 characters) is required on the *destination* file system. The *destination* file system can be FAT or NTFS. |
| /o | Copies file ownership and discretionary access control list (DACL) information. |
| /x | Copies file audit settings and system access control list (SACL) information (implies **/o**). |
| /exclude:FileName1\[+\[FileName2\]\]\[+\[FileName3\]( )\] | Specifies a list of files. At least one file must be specified. Each file contains search strings with each string on a separate line in the file. When any of the strings match any part of the absolute path of the file to be copied, that file is excluded from being copied. For example, specifying the string **obj** will exclude all files underneath the directory **obj** or all files with the **.obj** extension. |
| /y | Suppresses prompting to confirm that you want to overwrite an existing destination file. |
| /-y | Prompts to confirm that you want to overwrite an existing destination file. |
| /z | Copies over a network in restartable mode. |
| /b | Copies the symbolic link instead of the files. This parameter was introduced in Windows Vista®. |
| /j | Copies files without buffering. Recommended for very large files. This parameter was added in Windows Server 2008 R2. |
| /compress | Request network compression during file transfer where applicable. |
| /\[`-`\]sparse | Enables or disables retaining the sparse state of files during copy process. If both parameters are specified, **/-sparse** overrides **/sparse**. |
| /noclone | Doesn't attempt block cloning as an optimization. |
| /? | Displays help at the command prompt. |
## Remarks
- Using **/z**
If you lose your connection during the copy phase (for example, if the server going offline severs the connection), it resumes after you reestablish the connection. **/z** also displays the percentage of the copy operation completed for each file.
- Using **/y** in the COPYCMD environment variable.
You can use **/y** in the COPYCMD environment variable. You can override this command by using **/-y** on the command line. By default, you're prompted to overwrite.
- Copying encrypted files
Copying encrypted files to a volume that doesn't support EFS results in an error. Decrypt the files first or copy the files to a volume that does support EFS.
- Appending files
To append files, specify a single file for destination, but multiple files for source (that is, by using wildcards or file1+file2+file3 format).
- Default value for *destination*
If you omit *destination*, the `xcopy` command copies the files to the current directory.
- Specifying whether *destination* is a file or directory
If *destination* doesn't contain an existing directory and doesn't end with a backslash (), the following message appears:
Copy
```
Does <Destination> specify a file name or directory name on the target(F = file, D = directory)?
```
Press F if you want the file or files to be copied to a file. Press D if you want the file or files to be copied to a directory.
You can suppress this message by using the **/i** command-line option, which causes `xcopy` to assume that the destination is a directory if the source is more than one file or a directory.
- Using the `xcopy` command to set archive attribute for *destination* files
The `xcopy` command creates files with the archive attribute set, whether or not this attribute was set in the source file. For more information about file attributes and **attrib**, see [Related links](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#related-links).
- Comparing `xcopy` and `diskcopy`
If you have a disk that contains files in subdirectories and you want to copy it to a disk that has a different format, use the `xcopy` command instead of `diskcopy`. Because the `diskcopy` command copies disks track by track, your source and destination disks must have the same format. The `xcopy` command doesn't have this requirement. Use `xcopy` unless you need a complete disk image copy.
- Insufficient memory error
An "insufficient memory" error may occur if running `xcopy` to copy a file or folder whose filename path is greater than 255 characters.
- Exit codes for `xcopy`
To process exit codes returned by `xcopy`, use the **ErrorLevel** parameter on the **if** command line in a batch program. For an example of a batch program that processes exit codes using **if**, see [Related links](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#related-links). The following table lists each exit code and a description.
Expand table
| Exit code | Description |
|---|---|
| 0 | Files were copied without error. |
| 1 | No files were found to copy. |
| 2 | The user pressed CTRL+C to terminate `xcopy`. |
| 4 | Initialization error occurred. There isn't enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line. |
| 5 | Disk write error occurred. |
## Examples
**1\.** To copy all the files and subdirectories (including any empty subdirectories) from drive A to drive B, type:
Copy
```
xcopy a: b: /s /e
```
**2\.** To include any system or hidden files in the previous example, add the **/h** command-line option as follows:
Copy
```
xcopy a: b: /s /e /h
```
**3\.** To update files in the \\Reports directory with the files in the \\Rawdata directory that have changed since December 29, 1993, type:
Copy
```
xcopy \rawdata \reports /d:12-29-1993
```
**4\.** To update all the files that exist in \\Reports in the previous example, regardless of date, type:
Copy
```
xcopy \rawdata \reports /u
```
**5\.** To obtain a list of the files to be copied by the previous command (that is, without actually copying the files), type:
Copy
```
xcopy \rawdata \reports /d:12-29-1993 /l > xcopy.out
```
The file xcopy.out lists every file that is to be copied.
**6\.** To copy the \\Customer directory and all subdirectories to the directory \\\\Public\\Address on network drive H:, retain the read-only attribute, and be prompted when a new file is created on H:, type:
Copy
```
xcopy \customer h:\public\address /s /e /k /p
```
**7\.** To issue the previous command, ensure that `xcopy` creates the \\Address directory if it doesn't exist, and suppress the message that appears when you create a new directory, add the **/i** command-line option as follows:
Copy
```
xcopy \customer h:\public\address /s /e /k /p /i
```
**8\.** You can create a batch program to perform `xcopy` operations and use the batch **if** command to process the exit code if an error occurs. For example, the following batch program uses replaceable parameters for the `xcopy` source and destination parameters:
Copy
```
@echo off
rem COPYIT.BAT transfers all files in all subdirectories of
rem the source drive or directory (%1) to the destination
rem drive or directory (%2)
xcopy %1 %2 /s /e
if errorlevel 4 goto lowmemory
if errorlevel 2 goto abort
if errorlevel 0 goto exit
:lowmemory
echo Insufficient memory to copy files or
echo invalid drive or command-line syntax.
goto exit
:abort
echo You pressed CTRL+C to end the copy operation.
goto exit
:exit
```
To use the preceding batch program to copy all files in the C:\\Prgmcode directory and its subdirectories to drive B, type:
Copy
```
copyit c:\prgmcode b:
```
The command interpreter substitutes **C:\\Prgmcode** for *%1* and **B:** for *%2*, then uses `xcopy` with the **/e** and **/s** command-line options. If `xcopy` encounters an error, the batch program reads the exit code and goes to the label indicated in the appropriate **IF ERRORLEVEL** statement, then displays the appropriate message and exits from the batch program.
**9\.** This example copies all the non-empty directories, plus files with the associated file extension after the asterisk symbol.
Copy
```
xcopy .\toc*.yml ..\..\Copy-To\ /S /Y
rem Output example.
rem .\d1\toc.yml
rem .\d1\d12\toc.yml
rem .\d2\toc.yml
rem 3 File(s) copied
```
In the preceding example, this particular source parameter value **.\\toc\*.yml** copies the same 3 files even if its two path characters **.\\** were removed. However, no files would be copied if the asterisk wildcard was removed from the source parameter, making it just **.\\toc.yml**.
## Related links
- [Copy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/copy)
- [Move](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/move)
- [Dir](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dir)
- [Attrib](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/attrib)
- [Diskcopy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskcopy)
- [If](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/if)
- [Command-Line Syntax Key](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/command-line-syntax-key)
***
## Feedback
Was this page helpful?
Yes
No
No
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Ask Learn
Ask Learn
Suggest a fix?
***
## Additional resources
***
- Last updated on
05/28/2024
## In this article
1. [Syntax](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#syntax)
2. [Remarks](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#remarks)
3. [Examples](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#examples)
4. [Related links](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#related-links)
Was this page helpful?
Yes
No
No
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Ask Learn
Ask Learn
Suggest a fix?
## Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
[Sign in](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy)
[English (United States)](https://learn.microsoft.com/en-us/locale?target=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fwindows-server%2Fadministration%2Fwindows-commands%2Fxcopy)
[Your Privacy Choices](https://aka.ms/yourcaliforniaprivacychoices)
Theme
- Light
- Dark
- High contrast
- [AI Disclaimer](https://learn.microsoft.com/en-us/principles-for-ai-generated-content)
- [Previous Versions](https://learn.microsoft.com/en-us/previous-versions/)
- [Blog](https://techcommunity.microsoft.com/t5/microsoft-learn-blog/bg-p/MicrosoftLearnBlog)
- [Contribute](https://learn.microsoft.com/en-us/contribute)
- [Privacy](https://go.microsoft.com/fwlink/?LinkId=521839)
- [Consumer Health Privacy](https://go.microsoft.com/fwlink/?linkid=2259814)
- [Terms of Use](https://learn.microsoft.com/en-us/legal/termsofuse)
- [Trademarks](https://www.microsoft.com/legal/intellectualproperty/Trademarks/)
- © Microsoft 2026 |
| Readable Markdown | Copies files and directories, including subdirectories.
For examples of how to use this command, see [Examples](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#examples).
```
xcopy <Source> [<Destination>] [/w] [/p] [/c] [/v] [/q] [/f] [/l] [/g] [/d [:MM-DD-YYYY]] [/u] [/i] [/s [/e]] [/t] [/k] [/r] [/h] [{/a | /m}] [/n] [/o] [/x] [/exclude:FileName1[+[FileName2]][+[FileName3]]] [{/y | /-y}] [/z] [/b] [/j] [/compress]
```
| Parameter | Description |
|---|---|
| \<Source\> | Required. Specifies the location and names of the files you want to copy. This parameter must include either a drive or a path. |
| \[\<Destination\>\] | Specifies the destination of the files you want to copy. This parameter can include a drive letter and colon, a directory name, a file name, or a combination of these. |
| /w | Displays the following message and waits for your response before starting to copy files: **Press any key to begin copying file(s)** |
| /p | Prompts you to confirm whether you want to create each destination file. |
| /c | Ignores errors. |
| /v | Verifies each file as it is written to the destination file to make sure that the destination files are identical to the source files. |
| /q | Suppresses the display of `xcopy` messages. |
| /f | Displays source and destination file names while copying. |
| /l | Generates a list of files that are to be copied, but doesn't actively copy the files. |
| /g | Creates decrypted *destination* files when the destination doesn't support encryption. |
| /d \[:MM-DD-YYYY\] | Copies source files changed on or after the specified date only. If you don't include a *MM-DD-YYYY* value, `xcopy` copies all *source* files that are newer than existing *destination* files. This command-line option allows you to update files that have changed. |
| /u | Copies files from *source* that exist on *destination* only. |
| /i | If *source* is a directory or contains wildcards and *destination* doesn't exist, `xcopy` assumes *destination* specifies a directory name and creates a new directory. 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. |
| /s | Copies directories and subdirectories, unless they're empty. If you omit **/s**, `xcopy` works within a single directory. |
| /e | Copies all subdirectories, even if they're empty. Use **/e** with the **/s** and **/t** command-line options. |
| /t | Copies the subdirectory structure (that is, the tree) only, not files. To copy empty directories, you must include the **/e** command-line option. |
| /k | Copies files and retains the read-only attribute on *destination* files if present on the *source* files. By default, `xcopy` removes the read-only attribute. |
| /r | Copies read-only files. |
| /h | Copies files with hidden and system file attributes. By default, `xcopy` doesn't copy hidden or system files |
| /a | Copies only *source* files that have their archive file attributes set. **/a** doesn't modify the archive file attribute of the source file. For information about how to set the archive file attribute by using **attrib**, see [Related links](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#related-links). |
| /m | Copies *source* files that have their archive file attributes set. Unlike **/a**, **/m** turns off archive file attributes in the files that are specified in the source. For information about how to set the archive file attribute by using **attrib**, see [Related links](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#related-links). |
| /n | Creates copies by using the NTFS short file or directory names. **/n** is required when you copy files or directories from an NTFS volume to a FAT volume or when the FAT file system naming convention (that is, 8.3 characters) is required on the *destination* file system. The *destination* file system can be FAT or NTFS. |
| /o | Copies file ownership and discretionary access control list (DACL) information. |
| /x | Copies file audit settings and system access control list (SACL) information (implies **/o**). |
| /exclude:FileName1\[+\[FileName2\]\]\[+\[FileName3\]( )\] | Specifies a list of files. At least one file must be specified. Each file contains search strings with each string on a separate line in the file. When any of the strings match any part of the absolute path of the file to be copied, that file is excluded from being copied. For example, specifying the string **obj** will exclude all files underneath the directory **obj** or all files with the **.obj** extension. |
| /y | Suppresses prompting to confirm that you want to overwrite an existing destination file. |
| /-y | Prompts to confirm that you want to overwrite an existing destination file. |
| /z | Copies over a network in restartable mode. |
| /b | Copies the symbolic link instead of the files. This parameter was introduced in Windows Vista®. |
| /j | Copies files without buffering. Recommended for very large files. This parameter was added in Windows Server 2008 R2. |
| /compress | Request network compression during file transfer where applicable. |
| /\[`-`\]sparse | Enables or disables retaining the sparse state of files during copy process. If both parameters are specified, **/-sparse** overrides **/sparse**. |
| /noclone | Doesn't attempt block cloning as an optimization. |
| /? | Displays help at the command prompt. |
- Using **/z**
If you lose your connection during the copy phase (for example, if the server going offline severs the connection), it resumes after you reestablish the connection. **/z** also displays the percentage of the copy operation completed for each file.
- Using **/y** in the COPYCMD environment variable.
You can use **/y** in the COPYCMD environment variable. You can override this command by using **/-y** on the command line. By default, you're prompted to overwrite.
- Copying encrypted files
Copying encrypted files to a volume that doesn't support EFS results in an error. Decrypt the files first or copy the files to a volume that does support EFS.
- Appending files
To append files, specify a single file for destination, but multiple files for source (that is, by using wildcards or file1+file2+file3 format).
- Default value for *destination*
If you omit *destination*, the `xcopy` command copies the files to the current directory.
- Specifying whether *destination* is a file or directory
If *destination* doesn't contain an existing directory and doesn't end with a backslash (), the following message appears:
```
Does <Destination> specify a file name or directory name on the target(F = file, D = directory)?
```
Press F if you want the file or files to be copied to a file. Press D if you want the file or files to be copied to a directory.
You can suppress this message by using the **/i** command-line option, which causes `xcopy` to assume that the destination is a directory if the source is more than one file or a directory.
- Using the `xcopy` command to set archive attribute for *destination* files
The `xcopy` command creates files with the archive attribute set, whether or not this attribute was set in the source file. For more information about file attributes and **attrib**, see [Related links](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#related-links).
- Comparing `xcopy` and `diskcopy`
If you have a disk that contains files in subdirectories and you want to copy it to a disk that has a different format, use the `xcopy` command instead of `diskcopy`. Because the `diskcopy` command copies disks track by track, your source and destination disks must have the same format. The `xcopy` command doesn't have this requirement. Use `xcopy` unless you need a complete disk image copy.
- Insufficient memory error
An "insufficient memory" error may occur if running `xcopy` to copy a file or folder whose filename path is greater than 255 characters.
- Exit codes for `xcopy`
To process exit codes returned by `xcopy`, use the **ErrorLevel** parameter on the **if** command line in a batch program. For an example of a batch program that processes exit codes using **if**, see [Related links](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy#related-links). The following table lists each exit code and a description.
| Exit code | Description |
|---|---|
| 0 | Files were copied without error. |
| 1 | No files were found to copy. |
| 2 | The user pressed CTRL+C to terminate `xcopy`. |
| 4 | Initialization error occurred. There isn't enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line. |
| 5 | Disk write error occurred. |
**1\.** To copy all the files and subdirectories (including any empty subdirectories) from drive A to drive B, type:
```
xcopy a: b: /s /e
```
**2\.** To include any system or hidden files in the previous example, add the **/h** command-line option as follows:
```
xcopy a: b: /s /e /h
```
**3\.** To update files in the \\Reports directory with the files in the \\Rawdata directory that have changed since December 29, 1993, type:
```
xcopy \rawdata \reports /d:12-29-1993
```
**4\.** To update all the files that exist in \\Reports in the previous example, regardless of date, type:
```
xcopy \rawdata \reports /u
```
**5\.** To obtain a list of the files to be copied by the previous command (that is, without actually copying the files), type:
```
xcopy \rawdata \reports /d:12-29-1993 /l > xcopy.out
```
The file xcopy.out lists every file that is to be copied.
**6\.** To copy the \\Customer directory and all subdirectories to the directory \\\\Public\\Address on network drive H:, retain the read-only attribute, and be prompted when a new file is created on H:, type:
```
xcopy \customer h:\public\address /s /e /k /p
```
**7\.** To issue the previous command, ensure that `xcopy` creates the \\Address directory if it doesn't exist, and suppress the message that appears when you create a new directory, add the **/i** command-line option as follows:
```
xcopy \customer h:\public\address /s /e /k /p /i
```
**8\.** You can create a batch program to perform `xcopy` operations and use the batch **if** command to process the exit code if an error occurs. For example, the following batch program uses replaceable parameters for the `xcopy` source and destination parameters:
```
@echo off
rem COPYIT.BAT transfers all files in all subdirectories of
rem the source drive or directory (%1) to the destination
rem drive or directory (%2)
xcopy %1 %2 /s /e
if errorlevel 4 goto lowmemory
if errorlevel 2 goto abort
if errorlevel 0 goto exit
:lowmemory
echo Insufficient memory to copy files or
echo invalid drive or command-line syntax.
goto exit
:abort
echo You pressed CTRL+C to end the copy operation.
goto exit
:exit
```
To use the preceding batch program to copy all files in the C:\\Prgmcode directory and its subdirectories to drive B, type:
```
copyit c:\prgmcode b:
```
The command interpreter substitutes **C:\\Prgmcode** for *%1* and **B:** for *%2*, then uses `xcopy` with the **/e** and **/s** command-line options. If `xcopy` encounters an error, the batch program reads the exit code and goes to the label indicated in the appropriate **IF ERRORLEVEL** statement, then displays the appropriate message and exits from the batch program.
**9\.** This example copies all the non-empty directories, plus files with the associated file extension after the asterisk symbol.
```
xcopy .\toc*.yml ..\..\Copy-To\ /S /Y
rem Output example.
rem .\d1\toc.yml
rem .\d1\d12\toc.yml
rem .\d2\toc.yml
rem 3 File(s) copied
```
In the preceding example, this particular source parameter value **.\\toc\*.yml** copies the same 3 files even if its two path characters **.\\** were removed. However, no files would be copied if the asterisk wildcard was removed from the source parameter, making it just **.\\toc.yml**.
- [Copy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/copy)
- [Move](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/move)
- [Dir](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dir)
- [Attrib](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/attrib)
- [Diskcopy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskcopy)
- [If](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/if)
- [Command-Line Syntax Key](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/command-line-syntax-key) |
| Shard | 168 (laksa) |
| Root Hash | 14615152987638977768 |
| Unparsed URL | com,microsoft!learn,/en-us/windows-server/administration/windows-commands/xcopy s443 |