#!/bin/sh

tmpdir=`mktemp -td tracker.msword_filter.XXXXXXXXXX` || exit 1
tmpfile="$tmpdir"/tmpfile
tmptxtfile="$tmpdir"/tmptxtfile

cp "$1" "$tmpfile"

# Change the working directory to $tmpdir which we can safely delete later.
# Some distributions ship a version of wvText which extracts the image files
# from the word document and places them in the current working directory.

cd "$tmpdir"

nice -n19 wvText "$tmpfile" "$tmptxtfile" > /dev/null 2>&1

cat "$tmptxtfile"

rm -rf "$tmpdir"

