How to join two binary files on Windows

Viewed 28265

I created two binary files. I would like to concatenate both of them into one with the second one starting at offset firstFile.Size in the resulting file. I tried using a command in cygwin on Windows.

I entered the following command in cmd

cat file1.bin file2.bin > file3.bin

It generates an output file but it is 0 bytes in size. Does anyone know how this is done?

3 Answers

I didn't initially notice that the question was for Cygwin, Here is a solution for DOS anyway (not Cygwin).

Open a command prompt and type COPY /?

COPY lets you concatenate files by using the + operator

It also lets you designate them as binary by using the /B operator

So if you change to the directory with CD MyDir and run the following I would expect your concatentated file to be created

 COPY /B File1.bin + File2.bin file3.bin

To join two (or more) binary files together, the syntax is:

copy file1/b+file2/b file3/b

I use an a DOS or CMD window in an old XP machine to join two 100KB files together, and its almost instant.

In windows last version I have used HXD binary editor. In the file tools manu you have the option of concatenating bin files. Add them and then type the name of the resulting file. Execution is instantaneous.

Related