See also sgf, sgfcharset, sgfcheck, sgfcmp, sgfdb, sgfdbinfo, sgfinfo, sgfmerge, sgfstrip, sgftf, sgftopng, sgfvarsplit, sgfx, ugi2sgf.
% sgfsplit [-d#] [-s#] [-z] [-x prefix] [-F format] [-c] [-p] [files]
The utility sgfsplit reads one or more SGF files that contain collections of game records and splits them into files each containing a single game. Introductory text before each game is preserved. The output files get names produced from a format, by default "X-%04d.sgf" and a counter that counts from 1: X-0001.sgf, X-0002.sgf, ...
% sgfsplit -d0 < kisei.sgf % ls -1v X-1.sgf X-2.sgf ... X-119.sgf % sgfsplit -x Hon- honinbo.sgf % ls -1 Hon-0001.sgf Hon-0002.sgf ... Hon-0259.sgf % export LC_ALL=fa_IR.utf8 % sgfsplit -F "Judan-%I02u" judan.sgf % ls Judan-۱ Judan-۱۳ Judan-۱۷ Judan-۲۰ Judan-۲۴ Judan-۲۸ Judan-۴ Judan-۸ Judan-۱۰ Judan-۱۴ Judan-۱۸ Judan-۲۱ Judan-۲۵ Judan-۲۹ Judan-۵ Judan-۹ Judan-۱۱ Judan-۱۵ Judan-۱۹ Judan-۲۲ Judan-۲۶ Judan-۳ Judan-۶ judan.sgf Judan-۱۲ Judan-۱۶ Judan-۲ Judan-۲۳ Judan-۲۷ Judan-۳۰ Judan-۷
The inverse operation, that of combining games into a collection, is trivial:
% cat game*.sgf > collection.sgf
The number of games in a collection is reported by sgfinfo:
% sgfinfo -N guanzi_pu.sgf 1477
The utility sgf can also split collections. It removes leading and trailing junk, and also otherwise polishes the result. The present utility tries to change as little as possible, and only adds a final newline where needed.
See also sgfvarsplit, that splits a game into its variations.