Batch File to combine files


This page describes a batch file that I wrote to concatenate files into one large file. I guess that this is mainly useful for mpeg files.

The batch file is zipped up here.

It is used by going to the command (or MS-DOS) prompt and typing something like:
combine.bat \WebExcavator\downloads\*.mpg \WebExcavator\downloads\Combined\combined.mpg

The code looks like:
@if "%1" == "" goto usage
@if "%2" == "" goto usage

@echo combine %1 to %2

@if not exist %2 copy "empty.file" "%2"

@for %%x in (%1) do copy /B "%2"+"%%x" "%2"

goto exit

:usage
@echo Usage: combine.bat 'file to process (can include wild cards)' 'file name (can include directory to save to)'
@echo e.g. combine.bat *.txt temp\combined.txt

:exit

empty.file is, as the name implies, an empty file. It is used to get around an error that would occur if the file you were combining to doesn't exist.