命令行大全

copy

嚯嚯 发表于 2020-06-29 10:55浏览次数:

copy命令允许用户对一个或多个复制文件到备用位置。

copy命令用于完整文件,如果要复制一个目录或包含文件的多个目录,请使用robocopy或xcopy命令。

The copy command is used for complete files, if you want to copy a directory, or multiple directories containing files, use the robocopy or xcopy command.

查看英文版

目录:

1 copy 运行系统环境

2 copy 语法

3 copy 示例

copy 运行系统环境

Windows 95

Windows 98

Windows xp

Windows vista

Windows 2000

Windows 7

Windows 8

Windows 10

Windows NT

Windows ME

All Versions of MS-DOS

copy 语法

Windows Vista 及更高版本的语法

COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/L] [/A | /B ] source [/A | /B] [+ source [/A | /B] [+ ...]] 
[destination [/A | /B]]
source 指定要复制的文件。
/A 表示ASCII文本文件。
/B 表示二进制文件。
/D 允许解密创建目标文件。
destination 指定新文件的目录或文件名。
/V 验证新文件是否正确写入。
/N 复制具有非8dot3名称的文件时,使用短文件名(如果有)。
/Y 禁止提示您确认要覆盖现有的目标文件。
/-Y 导致提示您确认要覆盖现有目标文件。
/Z 以可重启模式复制网络文件。
/L 如果源是符号链接,则将链接复制到目标,而不是源链接指向的实际文件。

可以在COPYCMD环境变量中预设开关/ Y。在命令行上可以使用/ -Y覆盖此设置。缺省情况是提示覆盖,除非正在批处理脚本中执行COPY命令。

要附加文件,请为目标指定一个文件,但为源指定多个文件(使用通配符或file1 + file2 + file3格式)。

Windows XP 及更早版本的语法

COPY [/A | /B] source [/A | /B] [+ source [/A | /B] [+ ...]] [destination] [/A | /B]] [/V] [/Y | /-Y]
source 指定要复制的文件。
/A 表示ASCII文本文件。
/B 表示二进制文件。
destination 指定新文件的目录或文件名。
/V 验证新文件是否正确写入。
/Y 禁止提示您确认要覆盖现有的目标文件。
/-Y 导致提示您确认要覆盖现有目标文件。

开关/ Y可以在COPYCMD 环境变量中预设。在命令行上可以使用/ -Y覆盖此设置。

要附加文件,请为目标指定一个文件,但为源指定多个文件(使用通配符或file1 + file2 + file3格式)。

Windows Vista and later syntax

COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/L] [/A | /B ] source [/A | /B] [+ source [/A | /B] [+ ...]] 
[destination [/A | /B]]
source Specifies the file or files to be copied.
/A Indicates an ASCII text file.
/B Indicates a binary file.
/D Allow the destination file to be created decrypted.
destination Specifies the directory or file name for the new file(s).
/V Verifies that new files are written correctly.
/N Uses short file name, if available, when copying a file with a non-8dot3 name.
/Y Suppresses prompting to confirm you want to overwrite an existing destination file.
/-Y Causes prompting to confirm you want to overwrite an existing destination file.
/Z Copies networked files in restartable mode.
/L If the source is a symbolic link, copy the link to the target instead of the actual file the source link points to.

The switch /Y may be preset in the COPYCMD environment variable. This setting may be overridden with /-Y on the command line. The default is to prompt on overwrites unless COPY command is being executed from within a batch script.

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

Windows XP and earlier syntax

COPY [/A | /B] source [/A | /B] [+ source [/A | /B] [+ ...]] [destination] [/A | /B]] [/V] [/Y | /-Y]
source Specifies the file or files to be copied.
/A Indicates an ASCII text file.
/B Indicates a binary file.
destination Specifies the directory or file name for the new file(s).
/V Verifies that new files are written correctly.
/Y Suppresses prompting to confirm you want to overwrite an existing destination file.
/-Y Causes prompting to confirm you want to overwrite an existing destination file.

The switch /Y may be preset in the COPYCMD environment variable. This setting may be overridden with /-Y on the command line.

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

查看英文版

查看中文版

copy 示例

copy *.txt c:\

在上面的示例中,我们使用通配符将所有.txt文件(多个文件)从当前目录复制到c:\ 根目录。

copy *.* a:

将当前目录中的所有文件复制到软盘驱动器。

copy autoexec.bat c:\windows

复制通常在根目录下找到的autoexec.bat,并将其复制到Windows目录中;autoexec.bat可以代替任何文件。

copy win.ini c:\windows /y

将当前目录中的win.ini文件复制到Windows目录中。由于此文件已存在于Windows目录中,因此通常会提示您是否要覆盖该文件。但是,使用/ y开关,您将不会收到任何提示。

copy "computer hope.txt" hope

将文件“ computer hope.txt”复制到希望目录。每当处理带空格的文件或目录时,都必须用引号将其引起来。否则,您将收到“正在获取”命令的语法不正确。

copy myfile1.txt+myfile2.txt

在myfile2.txt和内容复制联合收割机它与myfile1.txt内容。

copy con test.txt

最后,用户可以使用如上所示的copy con命令创建一个文件,该文件将创建test.txt文件。键入上述命令后,用户可以键入他或她希望的任何内容。创建完文件后,可以按Ctrl + Z来保存和退出文件,这将创建^ Z,然后按Enter。在MS-DOS中查看和编辑文件的更简单方法是使用edit命令。

copy *.txt c:\

In the example above, we are using a wildcard to copy all .txt files (multiple files) from the current directory to the c:\ root directory.

copy *.* a:

Copy all files in the current directory to the floppy disk drive.

copy autoexec.bat c:\windows

Copy the autoexec.bat, usually found at root, and copy it into the Windows directory; the autoexec.bat can be substituted for any file(s).

copy win.ini c:\windows /y

Copy the win.ini file in the current directory to the Windows directory. Because this file already exists in the Windows directory it normally would prompt if you want to overwrite the file. However, with the /y switch you will not receive any prompt.

copy "computer hope.txt" hope

Copy the file "computer hope.txt" into the hope directory. Whenever you are dealing with a file or directory with a space, it must be surrounded with quotes. Otherwise, you'll get the "Getting "The syntax of the command is incorrect." error." error.

copy myfile1.txt+myfile2.txt

Copy the contents in myfile2.txt and combines it with the contents in myfile1.txt.

copy con test.txt

Finally, a user can create a file using the copy con command as shown above, which creates the test.txt file. Once the above command is typed in, a user could type in whatever he or she wishes. When you have completed creating the file, you can save and exit the file by pressing Ctrl+Z, which would create ^Z, and then press Enter. An easier way to view and edit files in MS-DOS would be to use the edit command.

如果存在隐藏文件,则不会复制它们。要复制所有文件(包括隐藏文件),请使用xcopy命令。

If there are hidden files, they're not copied. To copy all files including hidden files, use the xcopy command.

查看英文版

查看中文版