From 712b65c70003e0ba79aebd4c484e8042fb0c8005 Mon Sep 17 00:00:00 2001 From: PtJade Ceramic Date: Fri, 20 Jun 2025 01:08:11 +0800 Subject: [PATCH] Update `copy.md` to add `copy con` command Add a link to introduce DOS device names. Add an instance of `copy con` command. --- .../administration/windows-commands/copy.md | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/WindowsServerDocs/administration/windows-commands/copy.md b/WindowsServerDocs/administration/windows-commands/copy.md index 1a65ad132a..7f2eee864f 100644 --- a/WindowsServerDocs/administration/windows-commands/copy.md +++ b/WindowsServerDocs/administration/windows-commands/copy.md @@ -40,21 +40,21 @@ copy [/d] [/v] [/n] [/y | /-y] [/z] [/a | /b] [/a | /b] [+ [/a #### Remarks -- You can copy an ASCII text file that uses an end-of-file character (CTRL+Z) to indicate the end of the file. +- You can copy an ASCII text file that uses an end-of-file (EOF) character (⎈ Ctrl + Z) to indicate the end of the file. - If **/a** precedes or follows a list of files on the command line, it applies to all files listed until **copy** encounters **/b**. In this case, **/b** applies to the file preceding **/b**. The effect of **/a** depends on its position in the command-line string: - - If **/a** follows *source*, the **copy** command treats the file as an ASCII file and copies data that precedes the first end-of-file character (CTRL+Z). - - If **/a** follows *destination*, the **copy** command adds an end-of-file character (CTRL+Z) as the last character of the file. + - If **/a** follows *source*, the **copy** command treats the file as an ASCII file and copies data that precedes the first EOF character (⎈ Ctrl + Z). + - If **/a** follows *destination*, the **copy** command adds an EOF character (⎈ Ctrl + Z) as the last character of the file. - If **/b** directs the command interpreter to read the number of bytes specified by the file size in the directory. **/b** is the default value for **copy**, unless **copy** combines files. - If **/b** precedes or follows a list of files on the command line, it applies to all listed files until **copy** encounters **/a**. In this case, **/a** applies to the file preceding **/a**. The effect of **/b** depends on its position in the command–line string: - - If **/b** follows *source*, the **copy** command copies the entire file, including any end-of-file character (CTRL+Z). - - If **/b** follows *destination*, the **copy** command doesn't add an end-of-file character (CTRL+Z). + - If **/b** follows *source*, the **copy** command copies the entire file, including any EOF character (⎈ Ctrl + Z). + - If **/b** follows *destination*, the **copy** command doesn't add an EOF character (⎈ Ctrl + Z). - If a write operation cannot be verified, an error message appears. Although recording errors rarely occur with the **copy** command , you can use **/v** to verify that critical data has been correctly recorded. The **/v** command-line option also slows down the **copy** command, because each sector recorded on the disk must be checked. @@ -64,9 +64,9 @@ copy [/d] [/v] [/n] [/y | /-y] [/z] [/a | /b] [/a | /b] [+ [/a - If the connection is lost during the copy phase (for example, if the server going offline breaks the connection), you can use **copy /z** to resume after the connection is re-established. The **/z** option also displays the percentage of the copy operation that is completed for each file. -- You can substitute a device name for one or more occurrences of *source* or *destination*. +- You can substitute a [device name](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/DevNotes/rtlisdosdevicename_u.md) for one or more occurrences of *source* or *destination*. -- If *destination* is a device (for example, Com1 or Lpt1), the **/b** option 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 ENTER) to the device, as data. However, if you omit **/b**, the data is copied to the device in ASCII mode. In ASCII mode, special characters might cause files to combine during the copying process. +- If *destination* is a device (for example, Com1 or Lpt1), the **/b** option 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 ⎆ ENTER) to the device, as data. However, if you omit **/b**, the data is copied to the device in ASCII mode. In ASCII mode, special characters might cause files to combine during the copying process. - If you don't specify a destination file, a copy is created with the same name, modified date, and modified time as the original file. The new copy is stored in the current directory on the current drive. If the source file is on the current drive and in the current directory and you do not specify a different drive or directory for the destination file, the **copy** command stops and displays the following error message: @@ -89,7 +89,14 @@ copy [/d] [/v] [/n] [/y | /-y] [/z] [/a | /b] [/a | /b] [+ [/a ## Examples -To copy a file called *memo.doc* to *letter.doc* in the current drive and ensure that an end-of-file character (CTRL+Z) is at the end of the copied file, type: +To add the command `echo Hello, World!` as a batch file named `Hello.bat` to the current directory, type the following and press ⎈ Ctrl + Z and then ⎆ Enter: + +```cmd +copy con Hello.bat +echo Hello, World! +``` + +To copy a file called *memo.doc* to *letter.doc* in the current drive and ensure that an EOF character (⎈ Ctrl + Z) is at the end of the copied file, type: ``` copy memo.doc letter.doc /a @@ -125,7 +132,7 @@ To combine all files in the current directory that have the .txt file name exten copy *.txt Combined.doc ``` -To combine several binary files into one file by using wildcard characters, include **/b**. This prevents Windows from treating CTRL+Z as an end-of-file character. For example, type: +To combine several binary files into one file by using wildcard characters, include **/b**. This prevents Windows from treating ⎈ Ctrl + Z as an EOF character. For example, type: ``` copy /b *.exe Combined.exe