#!/bin/sh

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

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 abiword --to=text tmpfil > /dev/null 2>&1

cat tmpfil.text

rm -rf "$tmpdir"

