System command

xcopy command

Copy files and directory trees with selection and recursion options.

Availability: Microsoft Learn command reference spanning Windows client and Windows Server releases; some entries are legacy, role-specific, optional-feature or interactive subcommands.中文

Documented syntax

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]

The linked Microsoft Learn article is the upstream authority. Availability may depend on Windows release, role, optional feature or interactive tool context.

Examples

Example usage for xcopy.

xcopy C:\project D:\backup\project /e /i /y

Parameters, options and clauses

Option / clauseDescription
/sCopy non-empty directories and their subdirectories.
/eCopy all subdirectories, including empty ones.
/iAssume the destination is a directory when it does not exist.
/d[:date]Copy files changed on or after the specified date.
/hInclude hidden and system files.
/ySuppress overwrite confirmation prompts.
---Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
<Source>Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
[<Destination>]Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
/wMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/pMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/cMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/vMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/qMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/fMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/lMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
<Destination>Microsoft documents this argument or subcommand; check the linked reference for its required format and context.
/gMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/uMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/tMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/kMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/rMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/aMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/mMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/nMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/oMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/xMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/exclude:FileName1Microsoft documents this switch; use the linked reference for accepted values, effects and version limits.
-yMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/zMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/bMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/jMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
/compressMicrosoft documents this switch; use the linked reference for accepted values, effects and version limits.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory