0

I have different types of file in the same folder, which I have filtered and redirected to a list.txt file, using a separate script.

List.txt has the name of the binary files , which I need to combine together into one binary file.

>type list.txt
a.raw
b.raw
c.raw

Concatenate all the files present in the list.txt to a final.raw file.

>type < list.txt > final.raw
 The syntax of the command is incorrect.

Please let me know if there is any option to achieve this on windows cmdline or through some script file.

Note : manually both type and copy cmd is working properly for concatenation. need a script or cmd to do the same.

1 Answers1

0

If files to be concatenated are textual, then you may use

@echo.>final.raw && @for /f %x in (list.txt) do @type "%x" >> final.raw

If files to be concatenated are binary (really - in any case), then use

@echo.>final.raw && @for /f %x in (list.txt) do @copy /b final.raw+"%x" > nul

If filenames may contain spaces then use

@echo.>final.raw && @for /f "tokens=*" %x in (list.txt) do @copy /b final.raw+"%x" > nul

If the file final.raw already exists and may NOT be cleared then remove @echo.>final.raw && from the command line.

For using in .BAT file you may double each percent sign.

Akina
  • 3,295