COPY – DOS Command

It copies one or more files from one location to another location.

To view ‘copy’ with its all possible parameters you can use following command. Its like help information to regarding that command.

copy/?
Commands can be run using Microsoft Windows XP Command Prompt (cmd.exe)

Syntax :

	COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ]
        source [/A | /B][+ source [/A | /B] [+ ...]]
        [destination [/A | /B]]

where,

source 	: It specifies the file or files to be copied.

/A 	: It indicates an ASCII text file.

/B 	: It indicates a binary file.

/D 	: It allows the destination file to be created decrypted

destination : It specifies the directory and/or filename for 
              the new file(s).

/V 	: It verifies that new files are written correctly.

/N 	: It uses short filename, if available, when copying 
 	   a file with a non-8dot3 name.

/Y 	: It suppresses prompting to confirm you want to 
	  overwrite an existing destination file.

/-Y	 : It causes prompting to confirm you want to 
	   overwrite an existing destination file.

/Z 	: It copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable. This may be overridden with /-Y on the command line. 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).

Use 1:

copy *.* F:
– It copies all files from current directory to F:\ Drive.

Output 1:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > copy *.* F:
green1.txt
red1.txt
	2 file(s) copied.

D:\DINESH > _

Use 2:

copy green1.txt F:\ /y
– It copies file from current drive to F:\ without prompting to overwrite file if another same file found at F:\ Drive.

Output 2:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > copy green1.txt F:\
Overwrite F:\green1.txt? (Yes/No/All): n
	0 file(s) copied.

D:\DINESH > copy green1.txt F:\ /y
	1 file(s) copied.

D:\DINESH > _

Use 3:

copy green1.txt+red1.txt
– It copies the contents from red1.txt and joins or combines below the contents of green1.txt file.

Output 3:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH > copy green1.txt + red1.txt
green1.txt
red1.txt
	1 file(s) copied.

D:\DINESH > _

Use 4:

copy con test.txt
– It creates new blank text file at current directory. After entering this command press Enter then click Ctrl+Z to save work done and it will execute command.

Output 4:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

D:\DINESH >copy con test.txt
^Z
	1 file(s) copied.

D:\DINESH > _

Leave A Comment

Your email address will not be published. Required fields are marked *