Need to merge two files like, let’s say Textfile1.txt and Textfile2.txt into one single file? Easy, just use the old copy command to achieve this. Logo_cmd

To coy the contents of text files do:

copy file1.ext+file2.ext targetFile.ext

this will work as long as the files are plain text files (no Ctrl-Z characters inside the files)

If you need to merge binary files like .exe, .zip or one of those HJSplit, GSplit or a similar program that splitted files.. they usually are numbered like file.001, file.002 and so on, then use the /b parameter

copy /b file.001+file.002 file.bin

here are the possible copy command switches:

Copies one or more files to another location.

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

  source       Specifies the file or files to be copied.
/A           Indicates an ASCII text file.
  /B           Indicates a binary file.
/D           Allow the destination file to be created decrypted
destination  Specifies the directory and/or filename for the new file(s).
/V           Verifies that new files are written correctly.
/N           Uses short filename, if available, when copying a file with a
non-8dot3 name.
/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.
/Z           Copies networked files in restartable mode.
/L           If the source is a symbolic link, copy the link to the target
instead of the actual file the source link points to.

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

2 THOUGHTS ON “CMD: MERGE SPLITTED FILES USING COPY COMMAND”

  1. This works just fine.
    But the only problem when I use copy *.txt command to copy all text files in a directory. I need to add them in modified sequence. What I found was the command is considering the order of files to copy are arranged in name wise.

    Help me how to copy multiple files considering they are arranged as modified.

  2. To join files, such as clip.001 , clip.002, etc. use this command in Windows’ cmd:

    copy /b movieclip.* movieclip.avi

Advertisements