Search code examples
bin

How to join two binary files on Windows


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?


Solution

  • 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