Copy copies one or more files from one location to another location _dos/bat

Source: Internet
Author: User
Tags time and date
Copy
Copy one or more files from one location to another location.

Grammar
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 decrypted file at the destination.
/V
Verify that the new file is written correctly.
/n
Use the short file name (if any) when copying files with names longer than eight characters, or files with a file extension of more than three characters.
/y
Suppresses prompting you to confirm that you want to overwrite an existing destination file.
/-y
Prompts you to confirm that you want to overwrite an existing destination file.
/z
Copy the network files in restart mode.
/A
Indicates an ASCII text file.
/b
Indicates a binary file.
Source
You must specify the location of the file or set of files that you want to copy. Source can consist of a drive letter and a colon, a folder name, a file name, or a combination of those.
Destination
You must specify the location to which you want to copy the file or set of files. Destination can consist of a drive letter and a colon, a folder name, a filename, and a combination of those.
/?
Display Help at the command prompt.
Comments
You can copy ASCII text files that use the file end character (ctrl+z) to indicate the end of the file.
Use/A
When a/A is available before the file list on the command line, it applies to all files that are listed until copy encounters/b. In this case,/b applies to/b in front of the file.

When/A is immediately after the list of files on the command line, it applies to all files that are listed until copy encounters/b. In this case,/b applies to/b in front of the file.

The action of the/a parameter depends on its position in the command line string. When/a follows Source, copy treats the file as an ASCII (text) file and copies the data before the first file terminator.

When/a follows destination, copy adds a file terminator as the last character of the file.

Use/b
/b Specifies that the command interpreter reads the number of bytes specified by the file size in the directory. /b is the default value for copy, unless copy is used to merge files.

When/b precedes the list of files on the command line, it applies to all files that are listed until copy encounters/A. In this case,/a applies to the/A in front of the file.

When/b is located on the command line after the list of files, it applies to all listed files until copy encounters/A. In this case,/a applies to the/A in front of the file.

The role of/b depends on its position in the command line string. When/b follows Source, copy copies the entire file that contains any end of the file.

Copy does not add a file terminator when/b is immediately following destination.

Use/V
If the write operation is not validated, an error message appears. Although logging errors rarely occur with copy, you can still use/V to ensure that important data is correctly logged. Because you want to check each sector that is recorded on the drive, the/V command line option also slows down the copy command.

using/y and/-y
If you set up/y in the COPYCMD environment variable, you can replace the setting by using/-y at the command line. By default, you are prompted when you replace this setting, unless the copy command is executed in a batch script.

Ancillary files
To attach a file, specify a single file for destination, but specify multiple files for Source (using wildcard characters or file 1+ files in the format of File 3).

Using/z
If the connection is lost during the replication phase (for example, if the server is disconnected offline), copy/z will continue to replicate after the connection is reconnected. /z also displays the percentage of replication operations that have been completed for each file.

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

Use or omit/b when copying to a device
When destination is a device (for example, Com1 or LPT1),/b copies the 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, the data is copied to the device in ASCII mode. In ASCII mode, special characters can cause Windows XP to merge files during the replication process. For more information, see merging files.

Use default destination file
If you do not specify a destination 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 of the current drive. If the source file is in the current directory of the current drive, and you do not specify a different drive or directory for the destination file, the copy command terminates with the following error message:

File cannot be copied onto itself

0 File (s) copied

Merging files
If multiple source,copy separated by a plus sign (+) are specified, these files are merged into a single file. If a wildcard character (* or?) is used in source, but a single file name is specified in destination, copy merges all the files that match the file names in source and creates a single file using the filename specified in destination. In either case, copy assumes that the merged file is an ASCII file, unless the/b command-line option is used.

Copy 0 length files
Copy does not copy 0-byte-length files. Use xcopy to copy these files.

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

Copy/b source+,

The comma indicates that the destination parameter is omitted.

Copying files in subdirectories
To replicate all the files and subdirectories in the directory, you should use the Xcopy command. For more information about Xcopy, see.

The Recovery Console provides a copy command with different parameters.
Example
To copy the file Memo.doc to the Letter.doc in the current directory and make sure that the file terminator is at the end of the copied file, type:

Copy Memo.doc letter.doc/a

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 is copied to a file named birds in the disk root directory of drive C.

To copy several files into a file, you need to list several Source files, separated by a 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 place them in a file named "a" in the current directory of the current drive, type:

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

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

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

You can also combine several files into a single file by using the wildcard character (* or?). 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 binaries into a single file, add the/b command-line option. This prevents Windows XP from treating Ctrl+z as a file terminator. For example, type:

copy/b *.exe Combin.exe

Warning

If you merge binary files, the resulting file may not be available because of internal formatting.
In the following example, the Copy command merges 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 will combine File1.txt and file1.ref to form File1.doc, and copy will combine File2.txt with file2.ref to form File2.doc, and so on. For example, type:

Copy *.txt + *.ref *.doc

To merge all files that have a. txt extension, and then merge all files with the. ref extension and place the results of the merge 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.