|
Main
Date: 17 Jan 2006 01:02:46
From:
Subject: yahoo2pgn - a linux shell script for converting Yahoo! Chess files to pgn
|
I started playing Yahoo! Chess because it's easy to get a game started in my timezone. I like to let Fritz analyze my games, but the Yahoo! Chess file format cannot be read by ChessBase programs. So I wrote this little shell script to do it for me. Works on SuSE linux. Should work on any GNU linux. Doesn't work on OSX because of the BSD subsystem's strange 'date'. Please pass this along or tweak it or rewrite it in perl or ruby or something. Thanks, -eric --begin script--cut below this line-- #!/bin/sh # # converts chess files from yahoo format to pgn format # Copyright (C) 2006 Eric Sherman # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # http://www.gnu.org/copyleft/gpl.html ME=`basename $0` print_usage() { echo "$ME converts chess files from yahoo format to pgn format"; echo "Usage: $ME inFile outFile"; echo "Example: $ME game.yahoo game.pgn"; return } # not enough arguments if [ $# -lt 2 ] ; then print_usage exit 1 fi # file exists? if [ -e $1 ] ; then # convert yahoo date to pgn date/time according to local timezone DATEYAHOO=`grep Date $1
|
|
|
Date: 17 Jan 2006 20:02:11
From: primitiveworker
Subject: Re: yahoo2pgn - a linux shell script for converting Yahoo! Chess files to pgn
|
I'm usually content to simply get these kinds of quick-and-dirty scripts to work and then forget them. Thank you very much for your script-fu. The date format that yahoo produces just happens to be exactly the default output format of GNU's date -- "Tue Jan 17 20:59:41 MST 2006". (Fritz9 just arrived in the mail, yay.) -eric
|
| |
Date: 17 Jan 2006 23:54:08
From: Chris F.A. Johnson
Subject: Re: yahoo2pgn - a linux shell script for converting Yahoo! Chess files to pgn
|
On 2006-01-18, primitiveworker wrote: > I'm usually content to simply get these kinds of quick-and-dirty > scripts to work and then forget them. Thank you very much for your > script-fu. You're welcome. Could you (or anyone else) please send me a sample game in Yahoo format? > The date format that yahoo produces just happens to be exactly the > default output format of GNU's date -- "Tue Jan 17 20:59:41 MST 2006". This converts it to PGN format without using an external command: DATEYAHOO="Tue Jan 7 20:59:41 MST 2006" set -- $DATEYAHOO y=$6 m=$2 d=$3 PGNTIME=$4 ## Convert month name to number mm=JanFebAprMayJunJulAugSepOctNovDec idx=${mm%%$m*} m=$(( (${#idx} + 4 ) / 3 )) ## Pad month and day with 0 if necessary case $m in ?) m=0$m ;; esac case $d in ?) d=0$d ;; esac PGNDATE=$y.$m.$d -- Chris F.A. Johnson <http://cfaj.freeshell.org > =================================================================== Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
|
| | |
Date: 06 Jan 2007 13:23:57
From: Doug
Subject: Re: yahoo2pgn - a linux shell script for converting Yahoo! Chess files to pgn
|
Another alternative to convert games from yahoo to PGN is located he http://www.douglassdavis.com/pgnchess2006/ Just paste your game in the box on the left, choose the game result then click convert. Chris F.A. Johnson Wrote: > On 2006-01-18, primitiveworker wrote: > I'm usually content to simply get these kinds of quick-and-dirty > scripts to work and then forget them. Thank you very much for your > script-fu. > > You're welcome. > > Could you (or anyone else) please send me a sample game in Yahoo > format? > > The date format that yahoo produces just happens to be exactly the > default output format of GNU's date -- "Tue Jan 17 20:59:41 MS > 2006". > > This converts it to PGN format without using an external command: > > DATEYAHOO="Tue Jan 7 20:59:41 MST 2006" > set -- $DATEYAHOO > y=$6 > m=$2 > d=$3 > PGNTIME=$4 > > ## Convert month name to number > mm=JanFebAprMayJunJulAugSepOctNovDec > idx=${mm%%$m*} > m=$(( (${#idx} + 4 ) / 3 )) > > ## Pad month and day with 0 if necessary > case $m in ?) m=0$m ;; esac > case $d in ?) d=0$d ;; esac > > PGNDATE=$y.$m.$d > > > -- > Chris F.A. Johnson http://cfaj.freeshell.org > =================================================================== > Author: > Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress -- Doug
|
|
Date: 17 Jan 2006 21:30:34
From: Chris F.A. Johnson
Subject: Re: yahoo2pgn - a linux shell script for converting Yahoo! Chess files to pgn
|
On 2006-01-17, [email protected] wrote: > I started playing Yahoo! Chess because it's easy to get a game started > in my timezone. I like to let Fritz analyze my games, but the Yahoo! > Chess file format cannot be read by ChessBase programs. So I wrote > this little shell script to do it for me. > > Works on SuSE linux. Should work on any GNU linux. Doesn't work on > OSX because of the BSD subsystem's strange 'date'. Both BSD and GNU date have non-standard extensions. > Please pass this along or tweak it or rewrite it in perl or ruby or > something. Thanks, > -eric > > --begin script--cut below this line-- > #!/bin/sh [snip] > ME=`basename $0` With a POSIX shell such as bash or ksh, this external (i.e., slow) command is not needed: ME=${0##*/} > print_usage() { > echo "$ME converts chess files from yahoo format to pgn format"; > echo "Usage: $ME inFile outFile"; > echo "Example: $ME game.yahoo game.pgn"; > return > > } > > # not enough arguments > if [ $# -lt 2 ] ; then > print_usage > exit 1 > fi > > # file exists? > if [ -e $1 ] ; then > # convert yahoo date to pgn date/time according to local timezone > DATEYAHOO=`grep Date $1
|
|