Copy copies one or more files from one location to another

Time:2021-7-16

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

grammar
copy [/d] [/v] [/n] [{/y|/-y}] [/z] [{/a|/b}] Source [{/a|/b}] [+ Source [{/a|/b}] [+ …]][Destination [{/a|/b}]]

parameter
/d 
Allows the copied encrypted file to be saved as a decrypted file at the destination.  
/v 
Verify that the new file is written correctly.  
/n 
Use short file names (if any) when copying files with names longer than eight characters or file extensions longer than three characters.  
/y 
Do not prompt you to confirm that you want to overlay an existing target file.  
/-y 
Prompt you to confirm that you want to override the existing target file.  
/z 
Copy network files in restart mode.  
/a 
indicate   ASCII   Text file.  
/b 
Indicates the binary file.  
Source 
You must specify the location of the file or file set to copy. source   It can consist of a drive letter and colon, a folder name, a file name, or a combination of these.  
Destination 
You must specify the location to copy the file or file set to. Destination   It can be made up of a drive letter and colon, a folder name, a file name, and a combination of these.  
/? 
Display help at the command prompt.  
notes
You can copy characters that use the end of file  ( CTRL+Z)   To indicate the end of a file   ASCII   Text file.  
use  / a  
When there is a  / a   It applies to all listed files until   copy   encounter  / b。 In this case, / b   Apply to the  / b。

When  / a   When immediately following the file list on the command line, it applies to all listed files until   copy   encounter  / b。 In this case, / b   Apply to the  / b。

/a   The function of the parameter depends on its position in the command line string. When  / a   Follow closely   Source   After that, copy   Will treat the document as   ASCII (text) file and copies the data before the end of the first file.

When  / a   Follow closely   Destination   After that, copy   The end of file character is added as the last character of the file.

use  / b  
/b   Specifies that the command interpreter reads the number of bytes in the directory specified by the file size/ b   yes   copy   The default value of, unless   copy   Used to merge files.

When  / b   When preceded by the file list on the command line, it applies to all listed files until   copy   encounter  / a。 In this case, / A   Apply to the  / a。

When  / b   When placed after the file list on the command line, it applies to all listed files until   copy   encounter  / a。 In this case, / A   Apply to the  / a。

/b   The role of depends on its position in the command line string. When  / b   Follow closely   Source   After that, copy   Copies the entire file containing any end of file.

When  / b   Follow closely   Destination   After that, copy   The end of file is not added.

use  / v  
If the write operation cannot be verified, an error message appears. Despite the use of   copy   Logging errors rarely occur, but can still be used  / v   To ensure that important data has been correctly recorded. Because you want to check every sector recorded on the drive, the  / v   Command line options also make the   copy   The command slows down.

use  / y   and  /- y  
If in   COPYCMD   Environment variables are preset with  / y. You can use the  /- y   To replace the setting. By default, you are prompted to replace the setting unless the   copy   The command is executed in a batch script.

Subsidiary documents  
To attach a file, please   Destination   Specify a single file for the   Source   Specify multiple files (using wildcards or   file   1 + file   2 + files   three   Format).

use  / z  
If the connection is lost during the replication phase (for example, if the server is offline and disconnected), copy  / z   Replication will continue after the connection is reestablished/ z   The percentage of copy operations completed for each file is also displayed.

Copy to device and copy from device  
You can replace one or more occurrences with a device name   source   or   destination。

Use or omit when copying to a device  / b  
When   destination   Is a device (for example, COM1   or   Lpt1),/b   Data will be copied to the device in binary mode. In binary mode, copy  / b   All characters, including special characters, such as,   CTRL+C、CTRL+S、CTRL+Z   And newline characters, etc.) are copied to the device as data. However, if omitted  / b. Then the   ASCII   Mode copies data to the device. stay   ASCII   In mode, special characters may cause   Windows   XP   Merge files during replication. For more information, see merge files.

Use default target file  
If you do not specify a target file, a copy is created with the same name, creation date, and creation time as the source file, and the new copy is placed in the current directory on the current drive. If the source file is in the current directory on the current drive and you do not specify a different drive or directory for the target file, the   copy   The command will terminate with the following error message:

File cannot be copied onto itself

0 File(s) copied 

Merge files  
If the plus sign is specified  (+)  Separated multiple   source,copy   These files are merged into a single file. If in   source   The wildcard (*   or  ?), But in   destination   If a single file name is specified in the   copy   Will be all and   source   The file name in the   destination   To create a single file. Unless it’s used  / b   Command line option, otherwise in either case, copy   Assume that the merged file is   ASCII   Documents.

Copy zero length file  
Copy   It will not be copied   0   Byte long file. use   xcopy   Copy these files.

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

copy /b Source+,,

A comma indicates omission   Destination   Parameters.

Copy files in subdirectories  
To copy all the files and subdirectories in a directory, you should use the   xcopy   Orders. of   xcopy   For more information about, see.

The recovery console provides the   copy   Orders.  
example
To add a file   Memo.doc   To the current directory   Letter.doc, and make sure that the end of the copied file is the end of the file  

copy memo.doc letter.doc /a 

To add a file   Robin.typ   Copy from the current directory on the current drive to the   C   Existing directory on   Birds   Type:  

copy robin.typ c:\birds 

If   Birds   Directory does not exist, robin.typ   The file will be copied to the drive   C   In the root directory of the disk named   Birds   In the file.

To copy several files into one file, list several   Source   File, and the plus sign between the file names  (+)  Separate, and specify the file to include the merge result   Destination   Documents. For example, to add the   Mar89.rpt、Apr89.rpt   as well as   May89.rpt   Merge them and place them in the current directory of the current drive called   Report   , please type:  

copy mar89.rpt + apr89.rpt + may89.rpt report 

When merging files, copy   The target file is marked with the current date and time. If omitted   Destination, the file is merged and stored with the name of the first specified file. For example, to merge all four files into   Report, also known as   Report   , please type:  

copy report + mar89.rpt + apr89.rpt + may89.rpt 

You can also use the*   or  ?) To merge several files into one file. For example, in the current directory of the current drive, all  . exe   The file with the extension is merged into a file named   Combin.doc   , please type:  

copy *.txt combin.doc 

If you want to use wildcards to merge several binaries into one file, add  / b   Command line options. This can prevent   Windows   XP   take   CTRL+Z   Treat as end of file. For example, type:  

copy /b *.exe combin.exe 

warning

If you merge binaries, the resulting file may not be available because of its internal format.
In the following example, copy   The command sets each  . txt   The extension of the file and its corresponding  . ref   The files are merged. The result is the same file name with the extension  . doc   I’m not sure. copy   take   File1.txt   And   File1.ref   Merge to form   File1.doc, and then   copy   take   File2.txt   And   File2.ref   Merge to form   File2.doc, and so on. For example, type:

copy *.txt + *.ref *.doc 

To merge all  . txt   Extension, and then merge all files with  . ref   Extension and place the merge result in the   Combin.doc   File, please type:  

copy *.txt + *.ref combin.doc 

XOX