@echo off

rem http://www.open-aurec.com/wbforum/viewtopic.php?t=49535#p187097

type games\*.pgn > games.pgn 2> NUL

if "%~1" == "" (
set file=games
) else (
set file=%~1
)

if "%~2" == "" (
set zero=Alouette 0.1.7 32-bit [-r]
) else (
set zero=%~2
)

echo readpgn %file%.pgn> %~n0.params
echo elo>>  %~n0.params
echo mm>>  %~n0.params
echo exactdist>>  %~n0.params
echo offset 0 %zero%>>  %~n0.params
echo ratings ^>%~n0.log>>  %~n0.params
echo x>> %~n0.params
echo x>> %~n0.params

%~d0\applications\echecs\outils\bayeselo\bayeselo.exe < %~n0.params > NUL
rem del %~n0.params

type %~n0.log 2> NUL

exit /b 

rem Script for Bayeselo
rem Usage:
rem   ratings
rem   ratings myfile.pgn
rem   ratings myfile.pgn myengine
rem https://www.remi-coulom.fr/Bayesian-Elo/
rem http://www.open-aurec.com/wbforum/viewtopic.php?t=49535#p187097

if not exist bayeselo.exe (
echo Cannot find Bayeselo.
exit /b
)

if "%~x1" == ".pgn" (
set pgn=%~1
) else (
set pgn=games.pgn
)

if "%~2" neq "" (
set eng=%~2
) else (
set eng=Durandal 0.0.4 RND
)

echo readpgn %pgn%> %~n0.cfg
echo elo>> %~n0.cfg
echo mm>> %~n0.cfg
echo exactdist>> %~n0.cfg
echo offset 0 %eng%>> %~n0.cfg
echo ratings ^>%~n0.txt>> %~n0.cfg
echo x>> %~n0.cfg
echo x>> %~n0.cfg

%~d0\applications\echecs\outils\bayeselo\bayeselo.exe < %~n0.cfg > NUL

del %~n0.cfg
type %~n0.txt