Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment