#!/bin/sh

if [ "$1" = "" ]; then
	echo ""
	echo "Import "Plain-text" from Anki."
	echo "Enter the file name as an argument."
	echo ""
	exit 0;
fi

echo ""
echo "Adding from file: '"$1"'"

#et=`/bin/date -D "%F %H:%M" +%s`
et=9999999999
cat $1 | awk -v et=$et 'FS="\t" { gsub("<div>","",$0); gsub("</div>","",$0); gsub("<br />","  ",$0); gsub("&nbsp;"," ",$0); 
gsub("English =&gt; Polish  ","",$0); gsub("</ol>","",$0); gsub("</li>","",$0); gsub(/<ol class=\"[[:alnum:][:print:]]*>/,"",$0); 
gsub(/<li class=\"[[:alnum:][:print:]]*>/,", ",$0); print "0\t"et"\t0\t"et"\t"$1"\t"$2}' > $1.conv
echo ""
echo "Will be added the following words:"
echo ""
cat $1.conv
sleep 3	
cat $1.conv >> slowka
ile=`wc $1.conv | awk '{print $1}'`
echo ""
echo "Number of words "$ile
echo ""
echo ""



