sgfutils

The package sgfutils contains a few command line utilities that help working with SGF files that describe go (igo, weiqi, baduk) games. This page is about sgfmerge.

See also sgf, sgfcharset, sgfcheck, sgfcmp, sgfdb, sgfdbinfo, sgfinfo, sgfsplit, sgfstrip, sgftf, sgftopng, sgfvarsplit, sgfx, ugi2sgf.

sgfmerge

% sgfmerge [-c] [-d] [-m1] [files]
Take one or more SGF files and merge them. Little auxiliary utility used to combine several descriptions of the same game. All variations are stripped. Also the non-move properties are stripped everywhere, except from the first and last nodes. This makes
sgfmerge < single_file
useful.

Options:

-c
Strip comments. (By default, comments are stripped everywhere except at the root node and the final node. This strips them everywhere.)
-d
Error exit when duplicate fields occur. By default, sgfmerge will preserve all information in properties in the root node and final node, and only combine what is identical. When nodes are not identical, as in DT[1847-02-13] vs. DT[1847-03-29], both are written (and left for a human to examine). This option asks for an error exit in such a case.
-m1
By default, sgfmerge refuses to do anything when the games to be merged do not have identical move sequences. This option allows a single difference in the move sequences. One move sequence is given in the output, and the difference is mentioned in a game comment.
% sgfmerge LeeChangho-ChoHunhyun37450.sgf LeeChangHo-ChoHunHyun9201.sgf
sgfmerge LeeChangHo-ChoHunHyun9201.sgf: different moves (#23) ql and rl
% sgfmerge -m1 LeeChangho-ChoHunhyun37450.sgf LeeChangHo-ChoHunHyun9201.sgf
...
GC[Some sources have B 23 at rl]

;B[pd];W[dc];B[dp];W[qp];B[oq];W[jq];B[gq];W[mq];B[ce];W[cn]
;B[cp];W[ck];B[ci];W[cg];B[bg];W[gc];B[fd];W[fc];B[cc];W[cb]
;B[dd];W[ec];B[ql];W[po];B[qi];W[pq];B[bl];W[bk];B[bn];W[bf]
...

If you want to combine a number of games, problems, etc. into a single collection, just do

% cat game*.sgf > collection.sgf