Please help with .sh script

Hello experts... I have a unix .sh script and i need to convert it to a .bat script. I am a newbie and i came here for you`re help. so here we go:

#!/bin/sh

prefix=C:/GnuWin32
exec_prefix=${prefix}
datadir=${prefix}/share
tmpdir=${TMPDIR:-/tmp}

# argument checking
if [ ${#} -ne "2" ]; then
	echo "Usage: ${0} <word document> <text output file>"
	exit 1
fi

USE_DUMP=0
which elinks >/dev/null 2>&1
if [ ${?} -eq "0" ]; then
    USE_DUMP=3
else
    which links >/dev/null 2>&1
    if [ ${?} -eq "0" ]; then
	USE_DUMP=2
    else
	which lynx >/dev/null 2>&1
	if [ ${?} -eq "0" ]; then
	    USE_DUMP=1
	fi
    fi    
fi

if [ $USE_DUMP -eq "1" ]; then
	echo "Could not find required program 'elinks' or 'links'"
	echo "Using lynx. Ouput will be pretty ugly."
elif [ $USE_DUMP -eq "0" ]; then
	echo "Could not find required program 'elinks', 'links', or even 'lynx'"
	echo "Using wvWare -x wvText.xml. Ouput will be pretty bad."
fi

if [ $USE_DUMP -gt "0" ]; then

    # first, test for wvHtml
    which wvHtml >/dev/null 2>&1
    if [ ${?} -ne "0" ]; then
       	echo "Could not find required program 'wvHtml'"
	exit 1
    fi

    # intermediate file
    TMP_FILE=`mktemp "$tmpdir/wv-XXXXXX"`
    TMP_FILE=`basename "$TMP_FILE"`

    wvHtml -1 "${1}" --targetdir="${tmpdir}" "${TMP_FILE}" >/dev/null 2>&1
    if [ ${?} -ne "0" ]; then
	echo "Could not convert into HTML"
	exit 1
    fi

    if [ $USE_DUMP -eq "3" ]; then
	# elinks does the best
	elinks -dump -force-html "${tmpdir}/${TMP_FILE}" > "${2}"
    elif [ $USE_DUMP -eq "2" ]; then
	# links does a pretty good job
	links -dump "${tmpdir}/${TMP_FILE}" > "${2}"
    else
	# lynx sucks, but does better than wvText.xml
	TERM=vt100 lynx -dump -force_html "${tmpdir}/${TMP_FILE}" > "${2}"
    fi;

    if [ ${?} -ne "0" ]; then
	    echo "Could not convert into Text"
	    rm -f "${tmpdir}/${TMP_FILE}"
	    exit 1
    fi

    # clean up
    rm -f "${tmpdir}/${TMP_FILE}"

else
    # fall back onto our cruddy output
    # this is, admittedly, better than running
    # 'strings' on the word document though :)
    wvWare -x ${datadir}/wv/wvText.xml "${1}" > "${2}"
fi

this script is part of gnuwin32 conversion tool and should it convert .doc files in .txt files. Please help me!

Um.. .sh to .bat? No way. Approach this from trying to solve the problem the windows way.

Looks like all it's trying to do is convert a file found on the web to some kind of xml document.

An .sh file is not a .bat file. The capabilities are totally different (namely, .bat has almost none) and the tools quite different as well. There's no "conversion", just rewriting from scratch.

The script looks suspect anyway. I see nothing in it to convert .doc to .txt.

as i said: this script is part of gnuwin32 conversion tool and should it convert .doc files in .txt files... and i know that i cannot convert .sh to .bat and i asked here if someone helps me rewriting it cause i`m a newbie..... to see why i need it i will also post a link:

....sourceforge.net/projects/gnuwin32/forums/forum/74807/topic/1447151]SourceForge.net: GnuWin: Need to create a wvTEXT.exe

the project developer said that this script can easily be rewrited to .bat...and i ask for some help :slight_smile:

If that was the case then certainly he could have done so himself...

99% of the script is irrelevant to you since most of it is for dealing with lynx or links, things which don't understand .doc anyway, not to mention things you won't have under Windows.

I'd suggest trying wv itself except wv doesn't appear to have a Windows version available, in fact nothing but pure source code.