Powershell scripting: import twic PGN to Scid

How to import the weekly twic1)TWIC: The Week in Chess PGN4)PGN: Portable Game Notation to Scid vs. PC firstly manually then by PowerShell script in Windows 10?

Import manually the twic PGN to Scid

First of all, Mark Crowther compiles weekly chess games from the week’s tournaments in PGN and CBV format on his Twic site, which also publishes The Week in Chess magazine.

Start from 9:19s

To begin, download the last zipped PGN identified by a number as “1316” in a row of the “TWIC Downloads” table on January 29, 2020.

Then unzip the zipped archive containing the PGN.

Finally, import the twic PGN to Scid vs. PC through the menu:

Scid vs. PC menu "Tools" > "Import a PGN file..."

Automatically import twic PGN to Scid

Linux shell Bash .sh script

On July 31, 2015, KatolaZ created the script Bash twic_script.sh V 0.1 with the file extension .sh for Linux (Ubuntu, Debian, etc.) or Unix.

Consider the three steps implemented by the following utilities:

  • Firstly, wget to download the PGN Twic;
  • Secondly, unzip to decompress the zipped archive;
  • Thirdly, pgnscid to import twic PGN decompressed into Scid.

At first glance, the script focuses on automating the loop to download the PGN Twic from one issue to another, especially until the most recent one. In addition, the script uses the Linux Scidb variant.

Windows 10 Powershell Twic2Scid.ps1

First, Powershell is the language of command of Windows 10 that replaces the Cmd interpreter of MS-DOS2)MS-DOS: Microsoft Disk Operating System. A few days before April 1, 2015, Microsoft Mobile launched on the Microsoft Store “MS-DOS Mobile” for Smartphone Windows 8 Mobile classified for three age-old nostalgic and more users. Hence the expression: I have plenty of DOS.-compatible historical commands.

right click start button of Windows 10 > Windows Powershell

Then, after the Powershell prompt identified by “PS path“, enter the command “cd3)cd: change directory” to change the current directory in order to go into the directory created during the installation of Scid vs. PCs to find its databases:

PS C:\Users\Chess> cd C:\Chess\Scid\Prog\bin\bases
PS C:\Chess\Scid\Prog\bin\bases> # We are in the Scid folder of databases

In addition, create the “twic” sub-folder under “bin\bases” with the Windows 10 file manager. Under “twic” there is also the “pgn” folder:

Then, the old “Cmd” shell in several versions of Windows is still accessible from the Powershell console.

To concateate several PGNs into a single PGN, the fastest way is the command inherited from MS-DOS “copy” with as a joker “*.pgn”. The result of the concatenation “twic.pgn” is in the parent directory “twic” accessible via the relative path “..”:

PS C:\Chess\Scid\Prog\bin\bases\twic> cd pgn
PS C:\Chess\Scid\Prog\bin\bases\twic\pgn> cmd /C copy *.pgn ..\twic.pgn
twic1285.pgn
twic1286.pgn
...
twic1310.pgn
twic1311.pgn
        1 copied file(s).
PS C:\Chess\Scid\Prog\bin\bases\twic\pgn> cd ..
PS C:\Chess\Scid\Prog\bin\bases\twic> dir twic.pgn

    Folder: C:\Chess\Scid\Prog\bin\bases\twic

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       26/01/2020     13:31       94517379 twic.pgn

27 PGN twic unzipped still need 90 MB.

The concept of error is related to the tool that interprets the PGN. In the case of Scid vs. PC, it can detect Fischer’s Chess960 variant and illegal castling in blitz. An additional difficulty is that the colossal numbers of error lines have as reference the giant file of the concated PGN and not the corresponding erroneous PGN.

In addition, downloading multiple zipped archives corresponding to each twic PGN can overload the bandwidth of the web server.

For all these reasons, the user should try to allow time interval between his downloads in order to manage any errors in the current PGN and limit the bandwidth used on the twic server.

Architecture of Twic2Scid.ps1 script

download the twic of the week, decompress into PGN, import the twic PGN by creating the Scid base, optimize and detect PGN errors, update the base of reference

Let’s find the three key steps:

  • Firstly, Invoke-WebRequest in the DownloadPgn function to download the Twic PGN;
  • Secondly, Expand-Archive in ProcessTwic to decompress the zipped archive;
  • Thirdly, pgnscid.exe supplied in the bin folder of Scid and called in CheckPgn to create the twic base in Scid format as if it was to import the decompressed PGN.

The error management is able to find the line number of the illegal castling and suggest to edit the PGN in NotePad++ at the right line.

The script will also be able to filter chess games according to the Fischer random chess variant.

Download “Windows 10 Powershell Twic2Scid.ps1” Twic2Scid.zip – Downloaded 12 times – 7 KB

  1. First, in the Windows 10 file manager, create the “twic” sub-folder in the directory of chess databases already created by the Scid vs. Setup. PC “bin\bases”;
  2. Second, download the Twic2Scid.ps1 script in “bin\bases” from the blue download button above.
    Size .zip: 7 KB. Size .ps1: 22 KB. Powershell lines: 349
  3. Third, click the started button of Windows 10. Enter the letter “i” as ISE and then run the graphical interface5)GUI: Graphical User Interface of Powershell ISE.
    If the user can’t find the Powershell development Integrated Script Environment, set up Windows 10 to install Powershell ISE.
    Alternatively, the user can run the script in a Powershell console without the ISE GUI. Think about indicating the current folder by “.\” in front of the name of the script. Then the user has to conffigure the variables in the script.
  4. Fourth, in Windows Powershell ISE or NotePad++, set up the main variables in the script to line 76. Where is this script? Where the user installed Scid vs. Pc? NotePad++?
    CheckConfig will check if the configuration is correct.
    See the last chapter “The script language of Scid vs. “PC” to validate the constant $slotClipBase.
  5. Fifth, in the dark blue windows powershell console (ISE), enter the script name and validate by ENTER:
    .\Twic2Scid.ps1
    Or more easily, click the green triangle “Run the script” (F5) in the Powershell ISE toolbar to run the script.

Security when deleting files

The script will only start if in the PowerShell console, the user copies and pastes the running rights of a PowerShell script:

PS C:\Chess\Scid\Prog\bin\bases\twic> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process

Set-ExecutionPolicy must be done once in each PowerShell ISE session or PowerShell console.

Let’s start by looking at the security of delete operations in DeleteFile, DeleteBase, CleanTemporaryFile, DeleteChess960, BackupRefBase.

The “Yes for all” option is not managed. Switch the $isConfirm flag to $false to stop having to confirm each file deletion after a first use.

# (*) =>>> SECURITY: review the functions: DeleteFile, DeleteBase, CleanTemporaryFile, DeleteChess960, BackupRefBase
$isWhatif = $false # $true means that deleteFile displays the command without deletion otherwise $false mean do the deletion
$isConfirm = $true # $true means deleteFile asks for confirmation otherwise $false means do not confirm
function DeleteFile([string]$filename)
{
    if (Test-Path -Path "$filename" -PathType leaf)
    {
        if ($isWhatif)
        {   Remove-Item $filename -WhatIf}      # trace the command with parameter without deletion
        else
        {
            if ($isConfirm)
            { Remove-Item $filename -Confirm} # ask for confirmation before the deletion
            else
            { Remove-Item $filename}          # deletion without confirmation
        }
    }
}

After a few uses in confirmation mode, once the user trusts in this script, she will be later able to remove the “-confirmed” setting of Remove-Item by:

$isConfirm = $false

Alternatively, it is possible to inject the “-WhatIf” setting, which only displays the delete command without physically deleting the file.

$isWhatif = $true

Process error-free twic 1316 PGN of the week

Generally, during the import, the weekly twic PGN does not have any error once in the Scid base: this is the nominal case.

PS C:\Users\Chess> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process

PS C:\Users\Chess> C:\Chess\Scid\Prog\bin\bases\twic\Twic2Scid.ps1
The base of reference to be updated is: C:\Chess\Scid\Prog\bin\bases\GiantBase
You can press Ctrl+C to STOP the script at any time to keep the generated files.
Do you want to DOWNLOAD https://www.theweekinchess.com/zips/twic1316g.zip (y/[n]) : y
Try to download C:\Chess\Scid\Prog\bin\bases\twic\twic1316g.zip from https://www.theweekinche
ss.com/zips/twic1316g.zip
Please wait...
Time: 3s
Do you want to UNZIP .zip to generate C:\Chess\Scid\Prog\bin\bases\twic\twic1316.pgn (y/[n]) : y
C:\Chess\Scid\Prog\bin\bases\twic\twic1316.pgn has been successfully unzipped.
Converting file C:\Chess\Scid\Prog\bin\bases\twic\twic1316.pgn to Scid database twic:
Errors/warnings will be written to twic.err.

  [0% 10   20   30   40   50   60   70   80   90  100]
  [..................................................]

Database `twic': 4245 games, 2084 players, 38 events, 29 sites.
There were no warnings or errors.
Do you want to UPDATE the base of reference C:\Chess\Scid\Prog\bin\bases\GiantBase (y/[n]) : y
Save the Scid base of reference in C:\Chess\Scid\Prog\bin\bases\backup
Database "C:\Chess\Scid\Prog\bin\bases\GiantBase": 
3936048 games
Version: 4.0
Namebase: 261178 players, 51481 events, 29891 sites, 5677 rounds.

LastWriteTime          Length Name         
-------------          ------ ----         
29/01/2020 02:48:21 550835919 GiantBase.sg4
29/01/2020 02:48:21 184994438 GiantBase.si4
29/01/2020 02:48:21   4736392 GiantBase.sn4
24/01/2020 16:49:33      2971 GiantBase.txt

After MERGING the new PGN in Scid base of reference: C:/Chess/Scid/Prog/bin/bases/GiantBase
Database "C:\Chess\Scid\Prog\bin\bases\GiantBase": 
3940293 games
Version: 4.0
Namebase: 261699 players, 51496 events, 29893 sites, 5677 rounds.

LastWriteTime          Length Name         
-------------          ------ ----         
29/01/2020 17:05:44 551629928 GiantBase.sg4
29/01/2020 17:05:45 185193953 GiantBase.si4
29/01/2020 17:05:44   4744868 GiantBase.sn4
24/01/2020 16:49:33      2971 GiantBase.txt

Do you want to process the NEXT twic 1317 (y/[n]) :  

To conclude, the last question to the user suggests to process the next “1317” twic that does not exist still at the date of January 29 janvier, 2020.

Persistence of the next twic to be processed

The script persists on the hard drive in the current folder the next number of twic in order to continue next week without having to configure again the script.

View the generated Twic2Scid.psd1 configuration file in Windows 10 Accessories > NotePad or NotePad++.

The .psd1 file extension means data file of the PowerShell script of the same name .ps1

This text file contains the character string “1317” if the process of the previous “1316” twic has been successful.

Process twic 1312 PGN with illegal castling

First, if you don’t find an illegal castling, skip this paragraph at first glannce or read diagonally.

To start, in her favorite editor, the user puts in comment the current twic “1316” and removes the comment symbol “#” at the top of the line of the “1312” twic:

#$twicNbr = "1316" # The week in chess last number on January 29, 2020
$twicNbr = "1312" # The week in chess last number with illegal castling in the PGN

Then, if the user has already successfully processed a twic such as the “1316”, remove the configuration file Twic2Scid.psd1 for example with the Windows file manager, otherwise the script will offer to download the following “1317” twic. Be careful: do not to remove the .ps1 script itself. The .psd1 data file has the blue notepad icon.

Another method is to leave the lines $twicNbr unchanged with the original comments in the .ps1 then replace “1317” with “1312” in the Twic2Scid.psd1 configuration file before restarting the script.

PS C:\Chess\Scid\Prog\bin\bases\twic> C:\Chess\Scid\Prog\bin\bases\twic\Twic2Scid.ps1
The base of reference to be updated is: C:\Chess\Scid\Prog\bin\bases\RefTest
You can press Ctrl+C to STOP the script at any time to keep the generated files.
Do you want to DOWNLOAD https://www.theweekinchess.com/zips/twic1312g.zip (y/[n]) : 
Do you want to UNZIP .zip to generate C:\Chess\Scid\Prog\bin\bases\twic\twic1312.pgn (y/[n]) : y
C:\Chess\Scid\Prog\bin\bases\twic\twic1312.pgn has been successfully unzipped.
Converting file C:\Chess\Scid\Prog\bin\bases\twic\twic1312.pgn to Scid database twic:
Errors/warnings will be written to twic.err.

  [0% 10   20   30   40   50   60   70   80   90  100]
  [..................................................]

Database `twic': 7810 games, 1691 players, 37 events, 28 sites.
There were 1 errors or warnings; examine the file "twic.err"

C:\Chess\Scid\Prog\bin\bases\twic\twic1312.pgn:(game 3270, line 86359) Warning: illegal castling (O-O) in game Gelfand, B - Gareev, T, 2019

Do you want to EDIT C:\Chess\Scid\Prog\bin\bases\twic\twic1312.pgn in NotePad++ at line 86359 (y/[n]) : y
Fix the PGN issue editing in NotePad++ C:\Chess\Scid\Prog\bin\bases\twic\twic1312.pgn
Once the PGN fixed, RESTART this script answering 'n' or 'enter' about download and unzip

The syntactic analyzer captures the line number 86359 of the PGN error in order to go directly to the right line when editing the wrong PGN in NotePad++. The user should search contextually around the given error number:

86360: Qb2 28. Rd2 Bc3 29. Nxc3 Qxc3 30. Bg5 Nf6 31. O-O Qd4 0-1

Let’s take the case of “7. O-O-O.” On the other hand, it is not possible to castle again in “31. O-O” even if the White King has returned to his initial center square.

Fix the twic 1312 PGN with illegal castling in NotePad++

The user will have to find that she must delete the last move #31 while keeping the terminator game “0-1” in the NotePad++ editor. Save the fixed PGN and restart the script.

PS C:\Chess\Scid\Prog\bin\bases\twic> C:\Chess\Scid\Prog\bin\bases\twic\Twic2Scid.ps1
The base of reference to be updated is: C:\Chess\Scid\Prog\bin\bases\RefTest
You can press Ctrl+C to STOP the script at any time to keep the generated files.
Do you want to DOWNLOAD https://www.theweekinchess.com/zips/twic1312g.zip (y/[n]) : 
Do you want to UNZIP C:\Chess\Scid\Prog\bin\bases\twic\twic1312.pgn (y/[n]) : 
Process existing C:\Chess\Scid\Prog\bin\bases\twic\twic1312g.zip
Converting file C:\Chess\Scid\Prog\bin\bases\twic\twic1312.pgn to Scid database twic:
Errors/warnings will be written to twic.err.

  [0% 10   20   30   40   50   60   70   80   90  100]
  [..................................................]

Database `twic': 7810 games, 1691 players, 37 events, 28 sites.
There were no warnings or errors.
Do you want to UPDATE the base of reference C:\Chess\Scid\Prog\bin\bases\RefTest (y/[n]) : y
Save the Scid base of reference in C:\Chess\Scid\Prog\bin\bases\backup
Database "C:\Chess\Scid\Prog\bin\bases\RefTest": 
7810 games
Version: 4.0
Namebase: 1691 players, 37 events, 28 sites, 2167 rounds.

LastWriteTime        Length Name       
-------------        ------ ----       
15/01/2020 20:11:35 1560754 RefTest.sg4
15/01/2020 20:11:35  367252 RefTest.si4
15/01/2020 20:11:35   40893 RefTest.sn4

After MERGING the new PGN in Scid base of reference: C:/Chess/Scid/Prog/bin/bases/RefTest
Database "C:\Chess\Scid\Prog\bin\bases\RefTest": 
15620 games
Version: 4.0
Namebase: 1691 players, 37 events, 28 sites, 2167 rounds.

LastWriteTime        Length Name       
-------------        ------ ----       
26/01/2020 12:36:35 3121871 RefTest.sg4
26/01/2020 12:36:35  734322 RefTest.si4
26/01/2020 12:36:35   40893 RefTest.sn4

Do you want to process the NEXT twic 1313 (y/[n]) : 

Specifically, if the research for the illegal castling requires replaying the game on a chessboard:

  • First, Scid vs. PC menu “File” > “Open” the generated database twic.si4;
  • second, menu “Search” > “Head…” based on the names of the players.

Obviously, it is essential to close the twic.si4 base then Scid vs. PC before restarting the script with the fixed PGN.

ConvertFrom-String’s Artificial Intelligence

First, the comments between lines 78 and 110 of the script explains in detail the declarative creation of the syntactic analyzer of the twic.err text file.

# How to populate the template for IA-based ConvertFrom-String according to the programmation by examples?

Especially since in only two lines, the templatetwicErr identifies the two most representative and different errors.

$templateTwicErr = @'
{pgn*:C:\Chess\base\twic\twic1312.pgn}:(game {game:3270}, line {line:86359}) {type:Warning}: {error:illegal castling (O-O) in game Gelfand, B - Gareev, T, 2019}
{Pgn*:C:\Chess\base\twic\twic1296.pgn}:(game {game:2570}, line {line:63828}) {type:Error reading tag}: {error:[FEN "nrkrqbbn/pppppppp/8/8/8/8/PPPPPPPP/NRKRQBBN w DBdb - 0 1"]}
'@

Let’s start by looking at how the ConvertFrom-String syntactic analyzer generator uses an Artificial Intelligence technique based on examples powered by Microsoft Research. To take another example, the advanced article “FlashExtract: some prose about ConvertFrom-String” and the following articles such as “PGN parser in PowerShell” present more elaborate parsers. Let us recognize that the twic.err’s parser is much simpler and suitable for an introduction to this technique of syntactic analysis driven by the examples of the end user. Specifically, the CheckPgn function calls the ConvertFrom-String cmdlet driven by the template.

However, the use of the generated parser is limited to extracting the line number used by the script to drive NotePad++ when editing the wrong PGN. Let’s recognize that a direct string-based extraction based on the tokens “, line” and “)” would be faster but less generic.

Remove Chess960 from PGN 1296 base twic.si4

First, if you don’t find Chess960 variants, skip this paragraph at first glance or read diagonally. Specifically, this chapter shows how it is possible to automate the research of a string of character like “Chess960” in all parts of a Scid base, define the filter of the games that meet the criterion, delete symbolically, compact physically and ECO classify.

First, in Windows Powershell ISE, allow the definition of $twicNbr “1296” by removing the comment “#” in the first column:

# remote PGN on the internet identified by its twic number in string format:
#$twicNbr = "1316" # The week in chess last number on January 29, 2020
#$twicNbr = "1312" # The week in chess last number with illegal castling in the PGN
$twicNbr = "1296" # The week in chess last number containing Chess960 variant

Then, in the Windows file manager, delete the Twic2Scid.psd1 data text file to forget the persistence of the next TwicNbr.

Finally, launch the Twic2Scid.ps1 script thus configured in Windows Powershell ISE. If the user has already downloaded twic1296g.zip in a previous session, skip the download step.

PS C:\Chess\Scid\Prog\bin\bases\twic> C:\Chess\Scid\Prog\bin\bases\twic\Twic2Scid.ps1
The base of reference to be updated is: C:\Chess\Scid\Prog\bin\bases\RefTest
Do you want to DOWNLOAD https://www.theweekinchess.com/zips/twic1296g.zip (y/[n]) : 
Do you want to UNZIP .zip to generate C:\Chess\Scid\Prog\bin\bases\twic\twic1296.pgn (y/[n]) : y
C:\Chess\Scid\Prog\bin\bases\twic\twic1296.pgn has been successfully unzipped.
Converting file C:\Chess\Scid\Prog\bin\bases\twic\twic1296.pgn to Scid database twic:
Errors/warnings will be written to twic.err.

  [0% 10   20   30   40   50   60   70   80   90  100]
  [..................................................]

Database `twic': 2649 games, 1453 players, 32 events, 28 sites.
There were 240 errors or warnings; examine the file "twic.err"

The first five errors inside twic.err are:
C:\Chess\Scid\Prog\bin\bases\twic\twic1296.pgn:(game 2570, line 63828) Error: Invalid FEN: nrkrqbbn/pppppppp/8/8/8/8/PPPPPPPP/NRKRQBBN w DBdb - 0 1
C:\Chess\Scid\Prog\bin\bases\twic\twic1296.pgn:(game 2570, line 63828) Error reading tag: [FEN "nrkrqbbn/pppppppp/8/8/8/8/PPPPPPPP/NRKRQBBN w DBdb - 0 1"]
C:\Chess\Scid\Prog\bin\bases\twic\twic1296.pgn:(game 2570, line 63836) Error reading move in game Kasparov, G - Caruana, F, 2019: Nb3
C:\Chess\Scid\Prog\bin\bases\twic\twic1296.pgn:(game 2571, line 63854) Error: Invalid FEN: nrkrqbbn/pppppppp/8/8/8/8/PPPPPPPP/NRKRQBBN w DBdb - 0 1
C:\Chess\Scid\Prog\bin\bases\twic\twic1296.pgn:(game 2571, line 63854) Error reading tag: [FEN "nrkrqbbn/pppppppp/8/8/8/8/PPPPPPPP/NRKRQBBN w DBdb - 0 1"]

Do you want to REMOVE Chess960 games from the generated Scid twic (y/[n]) : y
Before deleting Chess960:
Database "twic": 
2649 games
Version: 4.0
Namebase: 1453 players, 32 events, 28 sites, 421 rounds.

After deleting Chess960 in the generated base but not in the PGN:
Database "twic": 
2569 games
Version: 4.0
Namebase: 1445 players, 30 events, 27 sites, 421 rounds.

Do you want to REVIEW twic in the GUI of Scid (y/[n]) : 
Are all issues FIXED (y/[n]) : y
Do you want to UPDATE the base of reference C:\Chess\Scid\Prog\bin\bases\RefTest (y/[n]) : y
Save the Scid base of reference in C:\Chess\Scid\Prog\bin\bases\backup
Database "C:\Chess\Scid\Prog\bin\bases\RefTest": 
18029 games
Version: 4.0
Namebase: 2907 players, 78 events, 55 sites, 2170 rounds.

LastWriteTime        Length Name       
-------------        ------ ----       
23/01/2020 17:45:00 3586853 RefTest.sg4
23/01/2020 17:45:00  847545 RefTest.si4
23/01/2020 17:45:00   59324 RefTest.sn4

After MERGING the new PGN in Scid base of reference: C:/Chess/Scid/Prog/bin/bases/RefTest
Database "C:\Chess\Scid\Prog\bin\bases\RefTest": 
20598 games
Version: 4.0
Namebase: 3996 players, 108 events, 80 sites, 2170 rounds.

LastWriteTime        Length Name       
-------------        ------ ----       
23/01/2020 17:49:17 4073649 RefTest.sg4
23/01/2020 17:49:17  968288 RefTest.si4
23/01/2020 17:49:17   76516 RefTest.sn4

To conclude, there are no more Chess960 variants in the twic.si4 base. In addition, the user does not want to verify this statement by validating by “ENTER” by default:

Do you want to REVIEW twic in the GUI of Scid (y/[n]) :

On the other hand, the user assumes that the fixed twic.si4 does not contain any other problems.

Are all issues FIXED (y/[n]) : y

It is true that answering this question automatically is out of the scope of this script, according to the large number of errors in twic.err

In fact all errors come only from Chess960 variants.

  • The user replies “n” or “ENTER”. Fix the PGN or twic.si4 apart from the resolved problems related to Chess960.
  • The user replies ‘y’. This means that she considers that the twic.si4 base is automatically fixed and is fully valid. The script merges twic.si4 with the base of reference.

The script language of Scid vs. PC

First, the reference manual of scid script language from Scid vs. PC has been online since 2013. In addition, the command are prefixed by “sc_” meaning Shane’s Chess.

Into the bargain, the user reading the C++ will read the more up-to-date comments in the source code:

C:\Chess\Scid\Source\scid_vs_pc-4.19\src\tkscid.cpp
// sc_game_flag:
//    If there is two args, this returns the specified flag status for the
//    specified game. If there are three args, the 2nd arg (0 or 1 or invert)
//    sets the specified flag for the game.
//    Flags that can be specified: delete, user, ...
//    Extra calling methods:
//      sc_game flag <flag> filter <0|1|invert> operates on all filtered games.

Additionally, the commands are also accessible on the current open base in the Scid.exe graphical interface. Consider, for example, checking the clipbase slot number in memory thanks to a Powershell script. This step is necessary during the preliminary phase of the configuration of Twic2Scid.ps1:

$slotClipBase = 9 # 1. Run Scid. 2. menu "Help" > "Startup window". 3. above "Keep", enter in the input field the command: "sc_info clipbase" without double quotes
$slotFirstBase = 1 # First opened base

Launch the Scid.exe graphical interface (GUI) from the Start button of Windows 10 or from the usual shortcut.

Scid vs. PC menu "Help" > "Startup window"
script scid sc_info clipbase

Copy the command “sc_info clipbase” in the clipboard (Ctrl+C) then paste (Ctrl+V) the content of the clipboard in the empty input area above the option [] “Keep open after startup”. After the prompt “>”, the answer “9” appears above.

A more complex Scid command is to display the main line of three variants identified by their ECO code with Scid extension:

foreach eco {A30u C50q E15m} {::splash::add [sc_eco summary $eco 0]}

The result is displayed above on several lines:

A30u [English: Symmetrical, Hedgehog, 8.Qxd4 d6]  1.c4 c5 2.Nf3 Nf6 3.g3 b6 4.Bg2 Bb7 5.O-O e6 6.Nc3 Be7 7.d4 cxd4 8.Qxd4 d6 

C50q [Giuoco Pianissimo: 4.d3 Nf6 5.O-O d6]  1.e4 e5 2.Nf3 Nc6 3.Bc4 Bc5 4.d3 Nf6 5.O-O d6 

E15m [Queen's Indian: Nimzowitsch, 5.b3 d5]  1.d4 Nf6 2.c4 e6 3.Nf3 b6 4.g3 Ba6 5.b3 d5 
E15m [Queen's Indian: Nimzowitsch, 5.b3 d5 6.cxd5]  1.d4 Nf6 2.c4 e6 3.Nf3 b6 4.g3 Ba6 5.b3 d5 6.cxd5 
E15m [Queen's Indian: Nimzowitsch, 5.b3 d5 6.Bg2]  1.d4 Nf6 2.c4 e6 3.Nf3 b6 4.g3 Ba6 5.b3 d5 6.Bg2 

Beside that, the language interpreted is Tcl/Tk.

In the Powershell script, the advanced functions ScidCmdCompactBase, ScidCmdClassifyEco and DeleteChess960 use the tcscid.exe interpreter identified by $runScidShell:

$ScidScript = Join-Path -Path $dirTwic -ChildPath "ScidScript.txt" # textual script file will be created
# Utility of type line of command in the Powershell console or Cmd console
$runPgnToBaseScid = Join-Path -Path $pathScid -ChildPath "pgnscid.exe" # Create a new Scid base from a PGN
$runScidShell = Join-Path -Path $pathScid -ChildPath "tcscid.exe"      # Interpreter to script a Scid base
$runScidCmd = Join-Path -Path $pathScid -ChildPath "scidt.exe"         # Scid base utility driven by options
# Windows tool requiring a mouse
$runScidGui = Join-Path -Path $pathScid -ChildPath "scid.exe"          # Graphic User Interface of Scid

In addition, RunScidScipt executes scid commands temporarily saved in the ScidScript.txt text file to automate the action of importing the twic PGN into Scid.

PS C:\Users\Chess> cd C:\Chess\Scid\Prog\bin
PS C:\Chess\Scid\Prog\bin> # l'invite de l'interpréteur Scid est pourcent
PS C:\Chess\Scid\Prog\bin> .\tcscid.exe
% sc_info clipbase
9
% exit
PS C:\Chess\Scid\Prog\bin>

However, the results of the Scid commands are not captured when invoked via the operator “&” from the external executable corresponding to the interpreter tcscid.exe called inside the Powershell script. In addition, the Start-Process cmdlet with all possible redirects does not seem to capture the result of Scid commands in their interpreter.

Furthermore, another scidt.exe interpreter of Scid commands, identified by $runScidCmd, is more modest because it is driven only by options. For instance, it allows statistics about the current Scid base to be displayed before and after its update.

C:\Chess\Scid\Prog\bin> scidt
usage: C:\Chess\Scid\Prog\bin\scidt -<option> <database>
 -i: General database information
 -d: Change description of database
 -l: List all games
 -c: Show compactness of database
 -C: Compact the database
 -n: Name information
 -N: Remove unused names from the namebase file
 -p[prefix]: list all players starting with prefix
 -e[prefix]: list all events starting with prefix
 -s[prefix]: list all sites starting with prefix
 -r[prefix]: list all rounds starting with prefix
 -S[sort-fields]: Sort the database
  Sort fields: date, year, event, site, round, white, black
      eco, result, length, rating, country
  Example: scidt -Syear,event,round,date myBase.si4

See also

Importer PGN twic vers Scid par script

Notes   [ + ]

1. TWIC: The Week in Chess
2. MS-DOS: Microsoft Disk Operating System. A few days before April 1, 2015, Microsoft Mobile launched on the Microsoft Store “MS-DOS Mobile” for Smartphone Windows 8 Mobile classified for three age-old nostalgic and more users. Hence the expression: I have plenty of DOS.
3. cd: change directory
4. PGN: Portable Game Notation
5. GUI: Graphical User Interface