@echo off

SETLOCAL

cd nij_metrics
SET EXEC=c:\python27\python.exe -O ..\..\show_nij_metrics.py
SET FNAME_BEGIN=..\user$_Trial$
SET FNAME_END=.pickle 

IF "%2" == "debug" GOTO debug
goto ndebug

:debug
SET DEBUG=-d ..\extract_data 
goto debug_next

:ndebug
SET DEBUG=
goto debug_next

:debug_next
IF "%1" == "images" GOTO step1_single
IF "%1" == "metrics" GOTO step2_single
IF "%1" == "csv" GOTO step3_single
IF "%1" == "minutiae" GOTO step4_single
IF "%1" == "" GOTO allsteps

echo Wrong syntax. The argument, if given, must be images, metrics, csv or minutiae
goto end

:allsteps
SET MULTI=1
GOTO step1

:step1_single
SET MULTI=0
:step1
SET OPTS=/LOW %EXEC% images -t ..\logs\images_trial_
SET BACKTO=step2
IF EXIST qmaps GOTO step1_next
mkdir qmaps
:step1_next
cd qmaps
GOTO run

:step2_single
SET MULTI=0
:step2
SET OPTS=/LOW %EXEC% metrics %DEBUG% -t ..\logs\metrics_trial_
SET BACKTO=step3
IF EXIST metrics GOTO step2_next
mkdir metrics
:step2_next
cd metrics
GOTO run

:step3_single
SET MULTI=0
:step3
SET OPTS=/LOW %EXEC% csv -t ..\logs\csv_trial_
SET BACKTO=step4
IF EXIST csv GOTO step3_next
mkdir csv
:step3_next
cd csv
GOTO run

:step4_single
SET MULTI=0
:step4
SET OPTS=/LOW %EXEC% minutiae -t ..\logs\minutiae_trial_
SET BACKTO=end
IF EXIST minutiae GOTO step4_next
mkdir minutiae
:step4_next
cd minutiae
GOTO run

:run
start %OPTS%01.log %FNAME_BEGIN%01%FNAME_END%
start %OPTS%02.log %FNAME_BEGIN%02%FNAME_END%
start %OPTS%03.log %FNAME_BEGIN%03%FNAME_END%
start %OPTS%04.log %FNAME_BEGIN%04%FNAME_END%
start %OPTS%05.log %FNAME_BEGIN%05%FNAME_END%
start %OPTS%06.log %FNAME_BEGIN%06%FNAME_END%
start %OPTS%07.log %FNAME_BEGIN%07%FNAME_END%
start %OPTS%08.log %FNAME_BEGIN%08%FNAME_END%
start %OPTS%09.log %FNAME_BEGIN%09%FNAME_END%
start %OPTS%10.log %FNAME_BEGIN%10%FNAME_END%
start %OPTS%11.log %FNAME_BEGIN%11%FNAME_END%
start %OPTS%12.log %FNAME_BEGIN%12%FNAME_END%
start %OPTS%13.log %FNAME_BEGIN%13%FNAME_END%
start %OPTS%14.log %FNAME_BEGIN%14%FNAME_END%
start /WAIT %OPTS%15.log %FNAME_BEGIN%15%FNAME_END%
IF %MULTI%==0 GOTO end
cd ..
GOTO %BACKTO%

:end
ENDLOCAL



