Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-users: Re: [Wireshark-users] merging many files using mergecap

From: Bill Meier <wmeier@xxxxxxxxxxx>
Date: Sun, 21 Feb 2010 15:30:55 -0500
Boonie wrote:
Thanks Olivier,

That does the job. It took me hours with finding a sollution. Thanks a lot. This is much better than doing it by hand.

If anyone can think of a way to solve this with a batch file, I'd like to hear that too.


One way:

Put the following (the stuff between the ---- lines) in a batch file
(Season to your taste).

------
setlocal
set foo=
for %%f in (*.pcap) do set foo=!foo! %%f
mergecap -w all.pcap %foo%
-------

(The above works if there are no spaces in the filenames.
 Some amount of fiddling around with quoting could probably
 be done to make a version with works with spaces in filenames).

Run the batch file in the dir with the files to be merged

** Note** cmd.exe (the Windows command line shell) needs to be invoked with /v:on to enable "delayed environment variable expansion".

See 'cmd /?' and 'set /?' for additional information on
delayed environment variable expansion.