Skip to content

Instantly share code, notes, and snippets.

@ligi
Forked from ildar/goproblems_get_n_sort.sh
Created July 28, 2014 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ligi/7d26500bd386372b3c98 to your computer and use it in GitHub Desktop.
Save ligi/7d26500bd386372b3c98 to your computer and use it in GitHub Desktop.
#!/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