Using copy command, we can copy files from one directory to another directory. This command is similar to the Linux cp command, but it does not match with the full functionality of cp. Windows copy command can be used to copy files only, we can’t copy directories.
A simple use of copy command is given below.
copy File Destinationpath
If you need to copy multiple files, then the syntax will be like below.
copy file1 file2 file3 Destinationpath
Examples:
To copy the file 1.doc loated at c:\data\documents to the directory c:\data\newdocs
c\> copy c:\data\documents\1.doc c:\data\newdocs\
When we specify a directory path as the destination, the files will be copied with the same name. We can assign a different name by specifying the new name in the destination path. Example is shown below.
As in example above, copy the file but name it as 2.doc
c\> copy c:\data\documents\1.doc c:\data\newdocs\2.doc
If the destination file already exists you will be prompted for confirmation. To suppress this confirmation you can use /Y switch with copy command. This would be useful if you are executing copy command from a batch file.
c\> copy /Y c:\dir1\subdir1\file1.txt c:\dir2\subdir2\file2.txt
If the destination file exists, the above command will overwrite the same without asking the user for confirmation.
Related Posts:
Xcopy command syntax and examples
{ 4 comments… read them below or add one }
Windows "copy" is funny. Type "copy 1 2" and the file "1" will be copied into a new file "2". Now separate them by a plus sign instead of a space (copy 1+2) and you'll concatenate 1 and 2 and replace the old file "1" with the result of the concatenation!
Yes, we can concatenate two or more files using copy command. You need to separate the list of files using +. You can redirect the resultant data to a new file also.
Copy 1+2 3
The above command will not alter the file 1. It creates a new file 3 with the concatenated data of 1 & 2. If no file name is provided it stores the result in the first file.
My Win7 cannot find a copy command, and when i run xcopy, a window flashes and exits.
how can i combine 2 .exe files and be able to use both after concatenation