Skip to content

Instantly share code, notes, and snippets.

@apetresc
Created June 29, 2010 09:50
Show Gist options
  • Save apetresc/457020 to your computer and use it in GitHub Desktop.
Save apetresc/457020 to your computer and use it in GitHub Desktop.
TWIG script to download all the SGFs from a specified page and organize them
#!/bin/bash
SGF_SRC_LIST=/home/adrian/usr/local/twig/urls.txt
SCRATCH_DIR=/home/adrian/usr/local/twig/cache
DESTINATION_DIR=/home/adrian/Go/Games/TWIG
mkdir $SCRATCH_DIR
cd $SCRATCH_DIR
wget -r -l inf -t1 -nd -N -np -A.sgf -erobots=off -i "$SGF_SRC_LIST"
for sgfFile in $SCRATCH_DIR/*.sgf
do
pw=$(grep -oE PW\\[.*\\] "$sgfFile")
pw=${pw:3:$(expr index "$pw" ] - 4)}
pb=$(grep -oE PB\\[.*\\] "$sgfFile")
pb=${pb:3:$(expr index "$pb" ] - 4)}
dt=$(grep -oE DT\\[.*\\] "$sgfFile")
dt=${dt:3:10}
#echo $dt-$pw-$pb
dest="$DESTINATION_DIR/$dt-$pw-$pb.sgf"
if [ -e "$dest" ]
then
# Do nothing
echo "Skipping $sgfFile"
else
cp -v "$sgfFile" "$dest"
fi
done
http://igo-kisen.hp.infoseek.co.jp/topics.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment