Created
July 21, 2014 08:03
-
-
Save ildar/f767761934161a4b0c97 to your computer and use it in GitHub Desktop.
GoProblems.com fetching and sorting
This file contains hidden or 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 -ef | |
URL=${URL:-http://www.goproblems.com/mkoff/goproblemsSGF.tgz} | |
WORKDIR=${WORKDIR:-.} | |
mkdir -p "$WORKDIR" | |
cd "$WORKDIR" | |
[[ -s goproblemsSGF.tgz ]] || \ | |
wget "$URL" | |
[[ -d goproblemsSGF ]] || \ | |
tar xzf goproblemsSGF.tgz | |
for f in goproblemsSGF/*sgf; do | |
LEVEL=`fgrep DI[ $f | sed 's|^.*DI\[||' | cut -d] -f1` | |
GENRE=`fgrep GE[ $f | sed 's|^.*GE\[||' | cut -d] -f1` | |
[[ -d "$LEVEL/$GENRE" ]] || mkdir -p "$LEVEL/$GENRE" | |
mv $f "$LEVEL/$GENRE" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the URL http://www.goproblems.com/mkoff/goproblemsSGF.tgz is not valid any more - the new one seems to be http://www.goproblems.com/offline/goproblemsSGF.tgz