@ECHO OFF
ECHO Spy485 Splitted Record in File.

ECHO.
SET /P IP1="Enter IP address device: "
SET /P PORT1="Enter COM-port NUMBER device: "

ECHO.
SET /P IP2="Enter IP address device partner: "
SET PORT1=COM%PORT1%
SET /P PORT2="Enter COM-port NUMBER device partner: "
SET PORT2=COM%PORT2%

ECHO.
SET /P TIME="Enter recording TIME of ONE FILE in minutes: "
SET /P SAVEPATH="Enter PATH to SAVE files: "
IF "%SAVEPATH%"=="" SET SAVEPATH=.

ECHO.
:CYCLE
FOR /F %%A IN ('TIME/T') DO SET curTime=%%A
FOR /F %%A IN ('DATE/T') DO SET curDate=%%A
SET FILENAME1="%SAVEPATH%\%IP1%-%PORT1% %curDate:~6,4%.%curDate:~3,2%.%curDate:~0,2% %curTime:~0,2%-%curTime:~3,2%.spy"
SET FILENAME2="%SAVEPATH%\%IP2%-%PORT2% %curDate:~6,4%.%curDate:~3,2%.%curDate:~0,2% %curTime:~0,2%-%curTime:~3,2%.spy"

IF -%IP2%== - (goto ONLYSTART1) else (goto START1AND2)

:ONLYSTART1
ECHO Start record file %FILENAME1% 
call .\spy485.exe IP=%IP1% PORT=%PORT1% TIME=%TIME% FILE=%FILENAME1%
goto END CYCLE

:START1AND2
ECHO Start record files:
ECHO %FILENAME1%
ECHO %FILENAME2%
start .\spy485.exe IP=%IP1% PORT=%PORT1% TIME=%TIME% FILE=%FILENAME1%
call .\spy485.exe IP=%IP2% PORT=%PORT2% TIME=%TIME% FILE=%FILENAME2%
goto END CYCLE


:END CYCLE
goto CYCLE


