# 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[4k] then it is moved into .\4k
# 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`
done
