REM This script gathers information about the HEC-WAT folder in a HEC-WAT installation
REM Call this batch file from another batch file.
REM This second batch file runs the Jython interpreter and Jython script.

REM --------------- NOTES ---------------
REM UNC paths are not supported in cmd. If accessing a network drive, need to map to a letter first.

REM @ECHO off

REM add new WAT locations to the list starting on line 12
set watLocations=^
	"C:\Programs\HEC-WAT-v1.1.0.657-CRT_Modified\HEC-WAT-v1.1.0.657-CRT_Modified\HEC-WAT",^
	"C:\Stone\Programs\HEC-WAT\HEC-WAT 1.0 with Apr2020 crt jar+scripting\HEC-WAT",^
    "D:\WAT\HEC-WAT 1.0 with 2019 URC jar updated\HEC-WAT",^
    "C:\Programs\HEC-WAT 1.0 with Apr2020 crt jar+scripting\HEC-WAT",^
    "D:\Programs\HEC-WAT 1.0 with Apr2020 crt jar+scripting\HEC-WAT",^
"C:\Data\WAT\HEC-WAT 1.0 with 2019 URC jar updated\HEC-WAT"

REM determine how many of the WAT locations exist on this user's computer
set counter=0
for %%i in (!watLocations!) do (
    if exist %%i (
        set /a counter+=1
    )
)

REM Iterate through WAT locations again
REM If more than one WAT location is found, prompt user to ask which WAT to user
REM If one WAT location is found, use this one
REM If no WAT locations are found, exit
for %%i in (!watLocations!) do (
    if exist %%i (
        ECHO File found: %%i
        if !counter! GTR 1 (
            set fileFound=
            set /p fileFound="Is this your WAT installation? (Y/N)"
            if not '!fileFound!'=='' set fileFound=!fileFound:~0,1!
            if '!fileFound!'=='y' (
            set hecWatDirectory=%%i
            goto :endofloop
            )
        ) else (
            set hecWatDirectory=%%i
            goto :endofloop
        )
    )
)

:endofloop
if '%hecWatDirectory%'=='' goto failed
ECHO Using WAT located at: %hecWatDirectory%
goto end

:failed
exit /b 1

:end
cd /d %hecWatDirectory%