#!/bin/sh
set -u -e
DO_MD5=""
usage() {
echo "usage: $0 [--md5] /path/to/dicts"
echo " write to stdout an html file that serves up all .xwd files inside /path/to/dicts"
echo " optionally, write dictName.md5 in dir for every dict."
exit 1
}
do_lang() {
LANG=$1
echo "
$LANG |
"
cd $LANG
for DICT in $(ls *.xwd); do
echo ""
echo " ${DICT%.xwd} | "
HEXCOUNT=$(hd $DICT | head -n 1 | awk '{print $6 $7 $8 $9}' | \
tr [a-f] [A-F])
DECCOUNT=$(echo "ibase=16;$HEXCOUNT" | bc)
echo "${DECCOUNT} | "
SIZE=$(ls -l $DICT | awk '{print $5}')
SIZE=$(((SIZE+1024)/1024))
echo "${SIZE}K | "
echo "
"
[ -n "$DO_MD5" ] && md5sum $DICT | awk '{print $1}' > $DICT.md5
done
cd ..
}
if [ $# -eq 2 ]; then
[ $1 = "--md5" ] || usage
DO_MD5=1
shift
fi
[ $# -eq 1 ] || usage
WD=$(pwd)
cd $1
DIRS=""
for DIR in $(ls); do
if [ -d $DIR ] && ls $DIR/*.xwd >/dev/null 2>&1; then
DIRS="$DIRS $DIR"
fi
done
echo ""
echo "Download dictionaries for:"
for DIR in $DIRS; do
echo " $DIR"
done
echo ".
"
echo ""
echo "Dictionary | Wordcount | Size |
"
for DIR in $DIRS; do
do_lang $DIR
done
echo "
"
echo ""
cd $WD