COPY Copies one or more files from one location to another

Source: Internet
Author: User

Copy
Copy one or more files from one location to another.

Syntax
Copy [/d] [/V] [/n] [{/Y |/-y}] [/Z] [{/A |/B}] source [{/ A |/B}] [+ source [{/A |/B}] [+...] [destination [{/A |/B}]

Parameters
/D
Allows you to save the copied encrypted file as a decryption file at the target location.
/V
Verify that the new file is written correctly.
/N
Use a short file name (if any) When copying a file with a name of more than eight characters or with a file extension of more than three characters ).
/Y
Do not prompt you to overwrite the existing target file.
/-Y
You are prompted to confirm that you want to overwrite the existing target file.
/Z
Copy network files in reboot mode.
/
Indicates an ASCII text file.
/B
Indicates a binary file.
Source
You must specify the location of the file or set to be copied. Source can be composed of a drive letter and a colon, a folder name, a file name, or a combination of the following.
Destination
You must specify the location where you want to copy files or file sets. Destination can be composed of a combination of a drive letter and a colon, a folder name, and a file name.
/?
Display help at the command prompt.
Note
You can copy ASCII text files that use the end character (CTRL + Z) to indicate the end of the file.
Use/
When/A exists before the file list of the command line, it applies to all listed files until copy encounters/B. In this case,/B applies to/B before the file.

When/A follows the file list on the command line, it applies to all listed files until copy encounters/B. In this case,/B applies to/B before the file.

The role of the/a parameter depends on its position in the command line string. When/A is followed by source, copy regards the file as an ASCII (text) file and copies the data before the first file Terminator.

When/A is followed by destination, copy adds the file Terminator as the last character of the file.

Use/B
/B specify the number of bytes specified by the file size in the command interpreter to read the directory. /B is the default value of copy, unless copy is used to merge files.

When/B is located before the file list on the command line, it applies to all listed files until copy encounters/. In this case,/a applies to/A before the file.

When/B is located behind the file list on the command line, it applies to all listed files until copy encounters/. In this case,/a applies to/A before the file.

/B depends on its position in the command line string. When/B is followed by source, COPY Copies the entire file that contains any file Terminator.

When/B is followed by destination, the file Terminator is not added to copy.

Use/V
If the write operation cannot be verified, an error message is displayed. Although the use of copy rarely records errors, you can still use/V to ensure that important data has been correctly recorded. This/V command line option also slows down the running of the Copy command because you want to check every sector recorded on the drive.

Use/y and/-y
If/Y is set in the copycmd environment variable, you can replace it with/-Y in the command line. By default, you will be prompted when you replace this setting, unless the Copy command is executed in the batch processing script.

Ancillary documents
To attach a file, specify a single file for destination, but specify multiple files for source (using wildcards or the format of file 1 + file 2 + file 3 ).

Use/Z
If the connection is lost during the replication phase (for example, if the server disconnects offline), copy/Z will continue the replication after the connection is established again. /Z also displays the percentage of completed copy operations for each file.

Copy to and from devices
You can replace the source or destination that appears one or more times with the device name.

Use or omit/B When copying to a device
When destination is a device (for example, COM1 or LPT1),/B Copies data to the device in binary mode. In binary mode, copy/B Copies all characters (including special characters, such as Ctrl + C, CTRL + S, CTRL + Z, and line breaks) to the device as data. However, if/B is omitted, data is copied to the device in ASCII mode. In ASCII mode, special characters may cause Windows XP to merge files during the copy process. For more information, see "Merge files ".

Use default target file
If the target file is not specified, a copy is created using the same name, creation date, and creation time as the source file, and the new copy is placed in the current directory of the current drive. If the source file is located in the current directory of the current drive and you do not specify another drive or directory for the target file, the copy command ends with the following error message:

File cannot be copied onto itself

0 file (s) Copied

Merge files
If multiple sources separated by the plus sign (+) are specified, copy merges these files into a single file. If the wildcard (* Or?) is used in the source ?), However, if a single file name is specified in destination, copy merges all files that match the file name in source and creates a single file using the file name specified in destination. Unless the/B command line option is used, in any case, copy assumes that the merged file is an ASCII file.

Copy a zero-length File
Copy does not copy files with a length of 0 bytes. Use xcopy to copy these files.

Change the time and date of the file
If you want to assign the current time and date to the file without modifying the file, use the following syntax:

Copy/B Source + ,,

Comma (,) indicates that the destination parameter is omitted.

Copy a file in a subdirectory
To copy all files and subdirectories in the directory, use the xcopy command. For more information about xcopy, see "".

The fault recovery console provides copy commands with different parameters.
Example
To copy the file memo.doc to letter.doc in the current directory, and ensure that the end of the copied file is the file Terminator, type:

Copy memo.doc letter.doc/

To copy the file Robin. typ from the current directory of the current drive to the existing Directory birds located on drive C, type:

Copy Robin. typ c: \ birds

If the birds directory does not exist, the Robin. typ file will be copied to the birds file under the root directory of the drive C.

To copy several files into a file, you need to list several source files, and separate them with the plus sign (+), and specify the destination file to contain the merged result file. For example, to merge mar89.rpt, apr89.rpt, and may89.rpt in the current directory of the current drive, and put them in a file named report under the current directory of the current drive, type:

Copy mar89.rpt + apr89.rpt + may89.rpt report

When a file is merged, copy uses the current date and time to mark the target file. If destination is omitted, the file is merged and stored with the name of the first specified file. For example, to merge all the four files into the report, and the file named report already exists, type:

Copy report + mar89.rpt + apr89.rpt + may89.rpt

You can also use the wildcard (* Or ?) To merge several files into a file. For example, in the current directory of the current drive, to merge all files with the. exe extension into a file named combin.doc, type:

Copy *. txt combin.doc

If you want to use wildcards to merge several binary files into one file, add the/B command line option. This prevents Windows XP from pressing CTRL + Z whenCompositionParts Terminator processing. For example, type:

Copy/B *. EXE combin.exe

Warning

If a binary file is merged, the result file may not be used because of the internal format.
In the following example, the copy command combines each file with the. txt extension with its corresponding. Ref file. The result is a file with the same file name but with the. Doc extension. Copy combines file1.txt and file1.ref to form file1.doc. Then copy combines file2.txt and file2.ref to form file2.doc. For example, type:

Copy *. txt + *. Ref *. Doc

To merge all files with the. txt extension, merge all files with the. Ref extension, and place the merge results in the combin.doc file, type:

Copy *. txt + *. Ref combin.doc

xox

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.