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 [-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


Strip comments. (By default, comments are stripped everywhere except at the root node and the final node. This strips them everywhere.)
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.
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]


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

% cat game*.sgf > collection.sgf