Created
June 29, 2010 09:50
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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