@echo off
set nbLine=60
set file=c:\temp\transaction.txt
set paramType=%1
set transactionMin=10000

REM keep nbline last lines

	set /a cnt=0
	for /f %%a in ('type "%file%"^|find "" /v /c') do set /a cnt=%%a
	set /A startLine = %cnt%-%nbLine%
	
	IF /I %startLine% LEQ 0 (
		SET /A startLine=0
	)
	
	rem echo %startLine%
	more +%startLine% %file% > %file%2
	move /y %file%2 %file% >nul
	
REM Read each line
	for /F "tokens=*" %%A in (%file%) do ( 
		
		rem echo %%A
		for /f "delims=, tokens=1" %%n in ("%%A") do set transactionTime=%%n
		rem echo %transactionTime%
		for /f "delims=, tokens=2" %%m in ("%%A") do set transactionType=%%m
		rem echo %transactionType%
		
		call :rechercheMin
		
		)

goto :end
	
:rechercheMin
REM cherche du minum
set "true="

if "%transactionType%" EQU "%paramType%" set true=1
if /I "%paramType%" EQU "all" set true=1

if defined true (
	rem echo correct
	if %transactionTime% LEQ %transactionMin% (
		rem echo correct2
		if "%transactionTime%" NEQ "timeout" (
			set transactionMin=%transactionTime%
			rem echo %transactionMin%
		)
	)
)
exit /B 0


:end
echo %transactionMin%