Cut Move in PGN
I want to delete all 12+ moves of each game from thousands of pgn files.
For example, from 12 movements to the end of the game.
Does anyone know how to do it?
HELP me : Cut Move in PGN
Moderator: Ras
-
janggi-korea
- Posts: 14
- Joined: Wed Jul 06, 2022 2:05 pm
- Full name: baek-sc
HELP me : Cut Move in PGN
안녕하세요?
-
janggi-korea
- Posts: 14
- Joined: Wed Jul 06, 2022 2:05 pm
- Full name: baek-sc
-
Dann Corbit
- Posts: 12808
- Joined: Wed Mar 08, 2006 8:57 pm
- Location: Redmond, WA USA
Re: HELP me : Cut Move in PGN
Assuming the game score is similar to other chesslike games, the solution is to tokenize the game moves, and then remove from the tail of the list. Most efficient in a compiled language, it could even be performed using sql. If the games are already in a sql database, it might even be trivial.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
-
glennsamuel32
- Posts: 137
- Joined: Sat Dec 04, 2010 5:31 pm
- Location: 223
Re: HELP me : Cut Move in PGN
janggi-korea wrote: ↑Fri Jul 07, 2023 9:47 am Cut Move in PGN
I want to delete all 12+ moves of each game from thousands of pgn files.
For example, from 12 movements to the end of the game.
Does anyone know how to do it?
1. Download the latest pgn-extract
https://www.cs.kent.ac.uk/~djb/pgn-extr ... xtract.exe
2. Place the pgn and pgn-extract into a folder, open a command prompt
3. Type pgn-extract --dropply 24 -onew.pgn xxx.pgn
This will remove the first 12 moves of each game
12 moves = 24 ply
xxx.pgn is your original pgn
new.pgn is the resulting pgn
If you have 1,000s of pgns, merge them all into one first
1. Place pgns into a folder and run the command
copy *.pgn new.pgn
2. You may have to clean the newly created pgn
pgn-extract -7 -C -onew.pgn xxx.pgn
3. Run pgn-extract with the dropply flag...
Judge without bias, or don't judge at all...
-
Ozymandias
- Posts: 1537
- Joined: Sun Oct 25, 2009 2:30 am
Re: HELP me : Cut Move in PGN
You can go with this tool:janggi-korea wrote: ↑Fri Jul 07, 2023 9:47 am Cut Move in PGN
I want to delete all 12+ moves of each game from thousands of pgn files.
For example, from 12 movements to the end of the game.
Does anyone know how to do it?
=========================(56) truncate =============================
"truncate" counts the number of plies (half-moves) and then removes
any plies occurring after a user-specified number. If a game has
fewer plies than the user-specified number, that game is output
without change. Results are not removed.
"truncate" removes existing "PlyCount" tags. New "PlyCount" tags can
be inserted using "plyCount".
"truncate" removes comments, nags, variations, and major symbolic
annotation symbols (!, !!, ?, ??, !?, ?!, +-, -+, +/-, -/+, +=,
=+, +/=, =/+, =, ~, and N), if present.
"truncate" removes "en passant" indicators "ep", "e.p." and "/ep",
if present, so that they do not distort the ply count.
Syntax: truncate filename.pgn maximum_plies
Example: truncate alpha.pgn 50
Output: outU.pgn
Comments:
1. To remove all game moves but leave the results:
truncate alpha.pgn 0
-
janggi-korea
- Posts: 14
- Joined: Wed Jul 06, 2022 2:05 pm
- Full name: baek-sc
Re: HELP me : Cut Move in PGN
to Ozymandias
you are right
Thank you.
You are a very good programmer.
you are right
Thank you.
안녕하세요?
-
Ozymandias
- Posts: 1537
- Joined: Sun Oct 25, 2009 2:30 am
Re: HELP me : Cut Move in PGN
To be clear, this Norm's work, I'm only a user.