xcopy-parameter explanation

Source: Internet
Author: User

xcopy--Directory Replication Commands
1. Function: Copies all files in the specified directory and directory together with the directory structure.
2. Type: External command
3. Format: XCOPY [Source disk:]〈 source path name 〉[target drive:] [target pathname][/s][/v][/e]
4. Instructions for use:
(1) xcopy is copy extension, you can copy the specified directory files and directory structure, but cannot copy hidden files and system files;
(2) When using the source drive letter, the source destination path name, the source file name at least one specified;
(3) Select/s to copy all the files under the source directory and its sub-directories. Unless you specify the/e parameter,/s does not copy an empty directory, and if you do not specify the/s parameter, xcopy copies only the files of the source directory itself, not the subdirectories below it;
(4) when the/V parameter is selected, the copied sectors of the pair are inspected, but the speed decreases. Xcopy

Copy files and directories, including subdirectories.

Grammar

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]

Parameters

Source

Necessary. Specifies the location and name of the file to be copied. The parameter must contain a drive or path.

Destination

Specifies the destination of the file to be copied. The parameter can contain a drive letter and colon, a directory name, a file name, or a combination of them.

/w

The following message is displayed and waits for your response before you begin copying the file:

Press any key to begin copying file (s)

/P

Prompts you to confirm that you want to create each target file.

/C

Ignore the error.

/V

Validate each file when writing to the destination file to ensure that the destination file is exactly the same as the source file.

/q

Suppresses the message "xcopy" is displayed.

/F

Displays the source and destination file names when copying.

/L

Displays a list of files to be copied.

/g

Creates a decrypted target file.

/ D [:MM-DD-YYYY]

Copies only those source files that have changed after a specified date or a specified date. If you do not include the "mm-dd-yyyy" value, xcopy copies any new "Source" files that are newer than the existing "Destination" file. This command-line option allows you to update a changed file.

/u

Copy only files that are already in "Destination" from "Source".

/I

If "Source" is a directory or contains wildcards, and "Destination" does not exist, "xcopy" assumes "Destination" specifies the directory name and creates a new directory. Then, "xcopy" copies all the specified files to the new directory. By default, Xcopy prompts you to specify whether "Destination" is a file or a directory.

/s

Copy non-empty directories and subdirectories. If you omit "/S", "Xcopy" will work in a single directory.

/E

Copy all subdirectories, including empty directories. Use the "/E" with the "/S" and the "/T" command-line options.

/t

Copies only the subdirectory structure (that is, the directory tree) and does not copy the files. To copy an empty directory, you must include the "/E" command-line option.

/k

Copies the file, leaving the property in the destination file if the source file has a read-only property. By default, Xcopy removes the read-only attribute.

/R

Copy the read-only file.

/h

Copy files that have hidden and system file properties. By default, xcopy does not copy hidden or system files.

/A

Copy only those source files that have the archive file property settings. "/A" does not modify the archive file properties of the source file. For information about how to set archive file properties by using "attrib", see Related Topics.

/m

Copy the source file that has the archive file property settings. Unlike "/a", "/M" closes the archive file attribute for the file specified in the source. For information about how to set archive file properties by using "attrib", see Related Topics.

/n

Creates a copy with an NTFS short file or directory name. "/n" is required to copy a file or directory from an NTFS volume to a FAT volume or when the target file system requires a FAT file system naming convention (that is, 8.3 characters). The target file system can be FAT or NTFS.

/O

Copy file ownership with discretionary access control List (DACL) information.

/x

Copies file audit settings and system access control List (SACL) information (including "/O").

/exclude: FileName1 [+[ FileName2]] [+[FileName3]]

Specifies a list of files that contain strings.

/y

Suppresses the prompt to confirm that you want to overwrite a target file that already exists.

/-y

Prompts you to confirm that you want to overwrite the target file that already exists.

/Z

Replicate over the network in restartable mode.

/?

Displays help at the command prompt.

Comments
?

Use "/V"

This command is not used by Windows XP and the Windows Server 2003 family products. This command is included only for compatibility with existing MS-DOS files, but because its functionality is automatically implemented, it does not work when used on the command line.

?

Use "/exclude"

Each string is listed in a separate row in each file. If any of the listed strings match any part of the absolute path of the file to be copied, the file is excluded from the replication process. For example, if you specify the string "/obj/", all files under the OBJ directory are excluded. If the string ". obj" is specified, all files with the. obj extension are excluded.

?

Use "/z"

If the connection is lost during replication (for example, if the server used for the connection is offline), the replication process resumes after the connection is re-established. "/Z" also displays the percentage of copy operations completed per file.

?

Using "/y" in the COPYCMD environment variable

You can use "/y" in the COPYCMD environment variable. Use "/-y" on the command line to overwrite the command. By default, you are prompted to overwrite unless you run "copy" from within a batch script.

?

Copy an encrypted file

Copying an encrypted file to a volume that does not support EFS results in an error. You should first decrypt the file or copy the file to a volume that supports EFS.

?

Append file

To append a file, specify a single target file, multiple source files (using wildcards or file1+file2+file3 format).

?

Default value for "Destination"

If you omit "Destination", the xcopy command copies the file to the current directory.

?

Specify whether "Destination" is a file or a directory

If "Destination" does not contain an existing directory and does not end with a backslash (/), the following message appears:

Does destination Specify a file name or directory name on the target (F = file, D = directory)?

If you want to copy one or more files to a file, press F. If you want to copy one or more files to a directory, press D.

Use the "/I" command-line option to suppress the message, which causes "xcopy" to determine that the destination is a directory if the source is multiple files or a directory.

?

To set the archive properties of the Destination file using the xcopy command

The xcopy command creates a file with the Archive property settings, regardless of whether this attribute is set in the source file. For more information about file properties and "attrib," see Related Topics.

?

Compare "xcopy" and "diskcopy"

If your disk's subdirectories contain files and you want to copy them to a disk with a different format, use the Xcopy command instead of using diskcopy. Because the "diskcopy" command is a track-by-track copy of the disk, the source and destination disks need to be in the same format. The "xcopy" command does not have this requirement. In general, use "xcopy" unless you need a full copy of the disk image.

?

An "xcopy" Exit code

To process the exit code returned by "Xcopy", use the "ErrorLevel" parameter on the "if" command line of the batch program. For an example of a batch program that uses "if" to process exit codes, see Related Topics. The following table lists each exit code and description.

Exit code Describe

0

There is no error in file replication.

1

The file to be copied was not found.

2

User presses CTRL + C to terminate the "Xcopy".

4

An initialization error has occurred. There is not enough memory or disk space, or an invalid drive name or syntax was entered on the command line.

5

A disk write error has occurred.

xcopy-parameter explanation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.