mardi 24 janvier 2017

Batch Script not parsing in IF Statment

might just be an early morning this for me but I'm having a batch script auto-get the PC time and check if a text file is empty and if it is i manually enter a time in format "HR:MIN" minus the quotes then i use delims to get individual variables for HR and for MIN and read them back as "HR:MIN" (just for testing purposes) but the script is returning just ":" without the variable values, im sure its something dumb im missing but please give me your insight. here is the section of code:

for %%a in ("C:\My Scripts\Temp Files\%DAY%.txt") do set size=%%~za
if %size% EQU 0 ( set /p Timeout=Time-Out: 
                      echo %Timeout%>nul
                      for /f "tokens=1 delims=:" %%i in ('echo %Timeout%') do set ToutHR=%%i
                      for /f "tokens=2 delims=:" %%i in ('echo %Timeout%') do set ToutMIN2=%%i
                      pause
                      echo Time-Out: %ToutHR%:%ToutMIN2%
                      pause )

and then it returns:

C:\My Scripts>test.bat
Time-Now: 9:29
Time-Out: 4:45
Press any key to continue . . .
Time-Out: ECHO is on.:
Press any key to continue . . .
1 was unexpected at this time.

Thanks Folks

Aucun commentaire:

Enregistrer un commentaire