COPY--Examples The following command copies a file and ensures that an end-of-file character is at the end of the copied file: copy memo.doc letter.doc /a To copy the NOTE.TXT file from the current drive and directory to the directory MYNOTES, and to prevent MS-DOS from prompting you before overwriting the destination file (if it already exists), type the following command: copy note.txt mynotes /y To copy a file named ROBIN.TYP from the current drive and directory to an existing directory named BIRDS that is located on drive C, type the following command: copy robin.typ c:\birds If the BIRDS directory doesn't exist, MS-DOS copies the file ROBIN.TYP into a file named BIRDS that is located in the root directory on the disk in drive C. To copy several files into one file, list any number of files as source parameters on the COPY command line. Separate filenames with a plus sign (+) and specify a filename for the resulting combined file, as the following example shows: copy mar89.rpt + apr89.rpt + may89.rpt report This command combines the files named MAR89.RPT, APR89.RPT, and MAY89.RPT from the current drive and directory and places them in a file named REPORT in the current directory on the current drive. When files are combined, the destination file is created with the current date and time. If you omit destination, MS-DOS combines the files and stores them under the name of the first specified file. For example, if a file named REPORT already exists, you can use the following command to combine all four files in REPORT: copy report + mar89.rpt + apr89.rpt + may89.rpt You can also combine several files into one by using wildcards, as the following example shows: copy *.txt combin.doc This command combines all files in the current directory on the current drive that have the extension .TXT into one file named COMBIN.DOC, also in the current directory on the current drive. If you want to combine several binary files into one by using wildcards, include the /B switch, as the following example shows: copy /b *.exe combin.exe This prevents MS-DOS from treating CTRL+Z as an end-of-file character. CAUTION: If you combine binary files, the resulting file might not be usable due to internal formatting. In the following example, COPY combines each file that has a .TXT extension with its corresponding .REF file. The result is a file with the same filename but with a .DOC extension. Thus, COPY combines FILE1.TXT with FILE1.REF to form FILE1.DOC. Then COPY combines FILE2.TXT with FILE2.REF to form FILE2.DOC, and so on. copy *.txt + *.ref *.doc The following COPY command combines first all files with the .TXT extension, then all files with the .REF extension into one file named COMBIN.DOC: copy *.txt + *.ref combin.doc Copying information from the keyboard The following COPY command copies what you type at the keyboard to the OUTPUT.TXT file: copy con output.txt After you type this command and press ENTER, MS-DOS copies everything you type to the file OUTPUT.TXT. When you are finished typing, press CTRL+Z to indicate that you want to end the file. The CTRL+Z character will appear on the screen as "Z". You can also end a COPY CON command by pressing the F6 key. When you press F6, it generates the CTRL+Z character, which appears on the screen as Z. The following example copies information from the keyboard to the printer connected to LPT1: copy con lpt1