Keywords: Online Go

Disort.sh is a utility which sorts the problems downloaded from goproblems.com into directories based on the content of the DI (difficulty) tag. It is therefore more accurate than using goproblemscom2gquiz.sh, although it does not sort by genre.

The recommended way to use disort.sh is to use goproblemscom2gquiz.sh first, and then run disort.sh within the genre directories. You can then re-organize the problems by exact strength.

disort.sh is included below:

# disort.sh by Oliver Richman on August 29th 2006.
# Works in bash (and cygwin for windows too!)
# Sorts .SGF files into directories based on the contents of the DI tag.
# ex. If the file contains DI\[5k\] then it is moved into .\5k
# Please do not redistribute modified versions of this file.

for fname in `ls -1 *.sgf` do

echo Processing $fname
grep "DI\[" $fname > tmp
sed 's/^.*DI\[//' tmp > tmp2
sed 's/].*$//' tmp2 > tmp3
mkdir `cat tmp3` 2>/dev/null
mv $fname `cat tmp3`


Modification of above script

This modification handles also the problem with files containing unicode characters in the same line as the DI-identifier ... and it is a bit faster :-)

The script uses the standard Linux tools: sed, expr (oh, and date, but that has no influence on the sort function).

# disortMOD.sh by RueLue Apr.2013
# (orig. by Oliver Richman 2006.)
# Works in bash (Linux, and in Cygwin [Windows] too!)
# Please test it in Mac and report!
# Sorts .SGF files into directories based on the contents of the DI tag.
# ex. If the file contains DI[4k] then it is moved into ./4k
# Please: this script is already fast compared to the original - make it faster!
echo " Beginning: `date`"
for fname in `ls -1 *.sgf`
  (( num++ ))
  printf " Processing file $num: $fname \r"
  dirname=`sed -n 's/^.*DI\[//;T ready;s/].*$//p;: ready' $fname`
  if [ "`expr length $dirname`" -gt "3" ]
    then dirname=${dirname:0:$(( `expr index "$dirname" ]` - 1 ))}
  mkdir $dirname 2>/dev/null
  mv $fname $dirname
printf "\n $num files, Finished: `date`"

For windows users there is a script at SortProblemsByRank.

If you already used the goproblems.com files in Gogrinder for a longer time, you have possibly given several tags to your files (e.g. not yet solved?). To sort the .sgf files and the corresponding .dat files simultaneously, use GoGrinder / update-disorted.sh

disort.sh last edited by on April 23, 2013 - 00:34
RecentChanges · StartingPoints · About
Edit page ·Search · Related · Page info · Latest diff
[Welcome to Sensei's Library!]
Search position
Page history
Latest page diff
Partner sites:
Go Teaching Ladder
Login / Prefs
Sensei's Library