Skip to content

Instantly share code, notes, and snippets.

@ildar
Created July 21, 2014 08:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ildar/f767761934161a4b0c97 to your computer and use it in GitHub Desktop.
Save ildar/f767761934161a4b0c97 to your computer and use it in GitHub Desktop.
GoProblems.com fetching and sorting
#!/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
@ligi
Copy link

ligi commented Jul 28, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment