Answers.Body: <p>As of 2017.04.01, <a href="https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/" rel="noreferrer">pgn-extract</a> (version 17-38) does provide variation splitting functionality via its --splitvariants flag. So, if you want this in a Windows/Linux/Mac OS environment it is available. Disclosure: I am the author of pgn-extract.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-01T10:03:48.530Z
Answers.Text: Welcome for joining. I've been using your software for long time, and it's great.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-02T11:31:31.530Z
Answers.Text: I am glad you like it.
Answers.UserDisplayName: kentdjb
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-14T21:43:58.170Z
Answers.Text: thanks, I used it before, good to know about this new feature.
Answers.UserDisplayName: Joe
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-01T08:46:29.207Z
Answers.LastActivityDate: 2017-04-01T08:46:29.207Z
Answers.UserDisplayName: kentdjb
Answers.Body: <p>The only one I've found that will probably do what you want is <a href="http://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/" rel="nofollow noreferrer">PGN Extract</a>. It's a command line tool, so hopefully you're comfortable with that. It has a Windows binary, but if you need it for Linux or Mac I hope you're comfortable with compiling from source.</p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>It appears PGN Extract will only separate unique games in a single PGN into multiple PGNs, not branches. Sadly PGN Split was one of a kind, and there doesn't appear to be a replacement. One of few programs that managed to disappear <em>completely</em> from the internet.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-05-03T14:23:03.910Z
Answers.Text: thanks, I used it a long time ago. Does it do what I want out of the box, or are you saying I need to recompile and modify it?
Answers.UserDisplayName: Joe
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-05-03T14:23:42.740Z
Answers.Text: Do you know what command-line options will do what the asker wants? I found PGN Extract when searching for an answer to his question, but couldn't find the feature he's asking for in the documentation.
Answers.UserDisplayName: dfan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-05-03T14:24:22.340Z
Answers.Text: @Joe From what I saw the option to [separate files](http://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/help.html#separate-output) sounds exactly like what you want.
Answers.UserDisplayName: MDMoore313
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-05-03T14:25:12.347Z
Answers.Text: @dfan the `Separate Output Files` (-E) looks likes it's it.
Answers.UserDisplayName: MDMoore313
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-05-03T14:40:57.970Z
Answers.Text: -E seems to take the specified games and output them to multiple files, rather than to turn one game into many games (one for each variation), which is what @Joe is requesting.
Answers.UserDisplayName: dfan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-05-03T14:44:59.123Z
Answers.Text: @dfan looking at it again, it separates them according to ECO code, so it's confusing to me but a good shot nonetheless.
Answers.UserDisplayName: MDMoore313
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-05-03T15:56:17.353Z
Answers.Text: hmm, looked at the docs and tried to use it, I don't think -E it does quite what I am looking for ...
Answers.UserDisplayName: Joe
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-05-03T16:05:49.007Z
Answers.Text: @Joe I think you're right, I think it will only separate *unique* games inside a single PGN into multiple PGNs, not branches. Oh well. I'll update my answer.
Answers.UserDisplayName: MDMoore313
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2013-05-03T14:19:29.050Z
Answers.LastActivityDate: 2019-09-02T10:54:30.797Z
Answers.LastEditDate: 2019-09-02T10:54:30.797Z
Answers.UserDisplayName: MDMoore313
Answers.Body: <p>This will do it.</p>
  
  <p><a href="https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/" rel="nofollow">https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/</a></p>
  
  <p>I built it on mac--works great.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-28T02:29:36.030Z
Answers.Text: PGN-extract is not the same thing as pgnsplit
Answers.UserDisplayName: Joe
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-23T00:36:55.757Z
Answers.LastActivityDate: 2016-03-23T00:36:55.757Z
Answers.UserDisplayName: Kevin
Answers.Body: <p>I don't understand what you meant by pgn split, but I once purchased a chess pgn book and it has all the games (312) in one pgn file. Now I need to split it into each chapter with exactly 12 games each. I searched over the internet and didn't manage to find anything helpful. So I wrote a python program to divide it into separate files.</p>
  <pre><code>import os
  
  name = 'Your pgn file here'
  units = 12
  test_sub = &quot;[E&quot;
  path = 'F:/Chess/pgns/'
  file = ''
  
  with open(path+name+'.txt', encoding=&quot;utf8&quot;) as f:
      test_str = f.read()
  
  # using list comprehension + startswith()
  # All occurrences of substring in string 
  res = [i for i in range(len(test_str)) if test_str.startswith(test_sub, i)]
  
  print('No of games in each pgn =',units)  
  print('Total games found =',len(res))
  print('Splitting',len(res),'games into',len(res)//units,'pgns.....')
  
  os.mkdir(path+name)
  
  for i in range(len(res)//units):
  
      file = path+name+'/'+name+'- Unit-'+str(i+1)+'.pgn'
  
      if i==len(res)//units-1:
          with open(file, 'w', encoding=&quot;utf8&quot;) as file:
              file.write(test_str[res[i*units]:len(test_str)])
      else:
          with open(file, 'w', encoding=&quot;utf8&quot;) as file:
              file.write(test_str[res[i*units]:res[(i+1)*units]-1])
  
  print('Success!!')
  </code></pre>
  <p>Note: This divides the given pgn into equal number of files mentioned as <code>units</code> in the program, it doesn't divide a pgn into separate pgn's based on variations.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-25T15:49:27.470Z
Answers.LastActivityDate: 2021-06-25T15:49:27.470Z
Answers.UserDisplayName: insearchofcode
Answers.Body: <p><a href="http://web.archive.org/web/20120317043018/http://home.online.no/~malin/sjakk" rel="noreferrer">Here is the author's page</a> courtesy of <a href="http://www.archive.org" rel="noreferrer">archive.org</a>.  The zip file on that page includes the readme.</p>
  
  <p><a href="http://web.archive.org/web/20120317043018/http://home.online.no/~malin/sjakk/download/PgnSplit.zip" rel="noreferrer">Direct download of the zip file</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2013-06-03T02:43:36.833Z
Answers.LastActivityDate: 2013-06-03T14:32:42.433Z
Answers.LastEditDate: 2013-06-03T14:32:42.433Z
Answers.UserDisplayName: Ryan Frame
Body: <p>A couple of places on the web mention a free utility called pgnsplit, that does the following:
  "A commandline tool to convert pgn-files including games with variation into pgn-files where each variation get its own game."</p>
  
  <p>Sadly, all links to it seem dead. Does anyone know if it is possible to download it anywhere, or to find similar functionality in any other common chess database software?</p>
  
Tags: <software><pgn>
Title: Is PGN split utility available anywhere?
ThreadText: # Is PGN split utility available anywhere?
  
  (Asked by: username_0 on 2013-05-03)
  
  A couple of places on the web mention a free utility called pgnsplit, that does the following:
  "A commandline tool to convert pgn-files including games with variation into pgn-files where each variation get its own game."
  
  Sadly, all links to it seem dead. Does anyone know if it is possible to download it anywhere, or to find similar functionality in any other common chess database software?
  
  **Tags:** software, pgn
  
  
  ---
  
  ## 5 answers
  
  ### Answer by username_7 on 2013-06-03. Score: 10 | Accepted answer
  
  [Here is the author's page](http://web.archive.org/web/20120317043018/http://home.online.no/~malin/sjakk) courtesy of [archive.org](http://www.archive.org). The zip file on that page includes the readme.
  
  [Direct download of the zip file](http://web.archive.org/web/20120317043018/http://home.online.no/~malin/sjakk/download/PgnSplit.zip)
  
  
  ---
  
  ### Answer by username_1 on 2017-04-01. Score: 12
  
  As of 2017.04.01, [pgn-extract](https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/) (version 17-38) does provide variation splitting functionality via its --splitvariants flag. So, if you want this in a Windows/Linux/Mac OS environment it is available. Disclosure: I am the author of pgn-extract.
  
  > **Comments:**
  > **username_2**: Welcome for joining. I've been using your software for long time, and it's great.  
  > **username_1**: I am glad you like it.  
  > **username_0**: thanks, I used it before, good to know about this new feature.  
  
  ---
  
  ### Answer by username_3 on 2013-05-03. Score: 3
  
  The only one I've found that will probably do what you want is [PGN Extract](http://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/). It's a command line tool, so hopefully you're comfortable with that. It has a Windows binary, but if you need it for Linux or Mac I hope you're comfortable with compiling from source.
  
  ---
  
  **Update**
  
  It appears PGN Extract will only separate unique games in a single PGN into multiple PGNs, not branches. Sadly PGN Split was one of a kind, and there doesn't appear to be a replacement. One of few programs that managed to disappear *completely* from the internet.
  
  > **Comments:**
  > **username_0**: thanks, I used it a long time ago. Does it do what I want out of the box, or are you saying I need to recompile and modify it?  
  > **username_4**: Do you know what command-line options will do what the asker wants? I found PGN Extract when searching for an answer to his question, but couldn't find the feature he's asking for in the documentation.  
  > **username_3**: @username_0 From what I saw the option to [separate files](http://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/help.html#separate-output) sounds exactly like what you want.  
  > **username_3**: @username_4 the `Separate Output Files` (-E) looks likes it's it.  
  > **username_4**: -E seems to take the specified games and output them to multiple files, rather than to turn one game into many games (one for each variation), which is what @username_0 is requesting.  
  > **username_3**: @username_4 looking at it again, it separates them according to ECO code, so it's confusing to me but a good shot nonetheless.  
  > **username_0**: hmm, looked at the docs and tried to use it, I don't think -E it does quite what I am looking for ...  
  > **username_3**: @username_0 I think you're right, I think it will only separate *unique* games inside a single PGN into multiple PGNs, not branches. Oh well. I'll update my answer.  
  
  ---
  
  ### Answer by username_5 on 2016-03-23. Score: 2
  
  This will do it.
  
  <https://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/>
  
  I built it on mac--works great.
  
  > **Comments:**
  > **username_0**: PGN-extract is not the same thing as pgnsplit  
  
  ---
  
  ### Answer by username_6 on 2021-06-25. Score: 2
  
  I don't understand what you meant by pgn split, but I once purchased a chess pgn book and it has all the games (312) in one pgn file. Now I need to split it into each chapter with exactly 12 games each. I searched over the internet and didn't manage to find anything helpful. So I wrote a python program to divide it into separate files.
  
  ```
  import os
  
  name = 'Your pgn file here'
  units = 12
  test_sub = "[E"
  path = 'F:/Chess/pgns/'
  file = ''
  
  with open(path+name+'.txt', encoding="utf8") as f:
      test_str = f.read()
  
  # using list comprehension + startswith()
  # All occurrences of substring in string 
  res = [i for i in range(len(test_str)) if test_str.startswith(test_sub, i)]
  
  print('No of games in each pgn =',units)  
  print('Total games found =',len(res))
  print('Splitting',len(res),'games into',len(res)//units,'pgns.....')
  
  os.mkdir(path+name)
  
  for i in range(len(res)//units):
  
      file = path+name+'/'+name+'- Unit-'+str(i+1)+'.pgn'
  
      if i==len(res)//units-1:
          with open(file, 'w', encoding="utf8") as file:
              file.write(test_str[res[i*units]:len(test_str)])
      else:
          with open(file, 'w', encoding="utf8") as file:
              file.write(test_str[res[i*units]:res[(i+1)*units]-1])
  
  print('Success!!')
  
  ```
  
  Note: This divides the given pgn into equal number of files mentioned as `units` in the program, it doesn't divide a pgn into separate pgn's based on variations.
  
  
  ---
  
  