Microsoft DOS copy command

Quick links

About copy
Availability
Syntax
Examples

About copy

Allows the user to copy one or more files to an alternate location.

Availability

The copy command is an internal command and is available in the below Microsoft operating systems.

All Versions of MS-DOS
Windows 95
Windows 98
Windows ME
Windows NT
Windows 2000
Windows XP
Windows Vista
Windows 7

Syntax

Copies one or more files to another location.

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 filename 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 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).

Examples

copy *.txt c:\

In the above copy command 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.

Note: If there are hidden files they will not be copied. To copy all files including hidden files use the xcopy command.

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 dealing with a file or directory with a space, it must be surrounded with quotes. Otherwise you'll get the "The syntax of the command is incorrect." 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 has been 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.

Additional information

  • See our copy definition for further information and related links on this term.