1
goto time

:time
set tm=%time%
set hh=%tm:~0,2%
set mm=%tm:~3,2%
set ss=%tm:~6,2%
set ms=%tm:~7,2%
goto date

:date
set dt=%date%
set wd=%dt:~0,3%
set mh=%dt:~4,2%
set dy=%dt:~6,2%
set yr=%dt:~8,4%
goto scheduletimes

:scheduletimes
goto hour1
:hour1
for /f "tokens=1*delims=0" %%a in ("$0%hh%") do set /a "HH"="%%b"
if %HH% equ 6 goto minutes1
pause
goto time
:minutes1
for /f "tokens=1*delims=0" %%a in ("$0%mm%") do set /a "MM"="%%b"
if "%MM%"=="00" goto seconds1
pause
goto time
:seconds1
for /f "tokens=1*delims=0" %%a in ("$0%ss%") do set /a "SS"="%%b"
if %SS% lss 10 goto day1
pause
goto time

:day1
echo success
echo %hh%
echo %mm%
echo %ss%
pause 
goto time

As you guys can see this is a time check loop. Seeing if the time is 6:10:>10. Basically what my problem is though is that it runs fine until it executes the command when it hits that time. As soon as it becomes <10 seconds in this section:

:minutes1
for /f "tokens=1*delims=0" %%a in ("$0%mm%") do set /a "MM"="%%b"
if %MM% equ 0 goto seconds1

it stops setting MM to %mm% and it gives me a Missing Operand error.

Any help would be appreciated to get it to continue working after the first run.

(Yes I do know there are pauses and no @echo off, This is for debugging purposes. It does it with the @echo off and without the pauses too)

Edit: Log

C:\Users\krato_000\Desktop>goto scheduletimes

C:\Users\krato_000\Desktop>goto hour1

C:\Users\krato_000\Desktop>for /F "tokens=1*delims=0" %a in ("$0 6") do set /a "
HH"="%b"

C:\Users\krato_000\Desktop>set /a "HH"=" 6"

C:\Users\krato_000\Desktop>if 6 EQU 6 goto minutes1

C:\Users\krato_000\Desktop>for /F "tokens=1*delims=0" %a in ("$000") do set /a "
MM"="%b"

C:\Users\krato_000\Desktop>set /a "MM"=""
Missing operand.

C:\Users\krato_000\Desktop>if "00" == "00" goto seconds1

C:\Users\krato_000\Desktop>for /F "tokens=1*delims=0" %a in ("$019") do set /a "
SS"="%b"

C:\Users\krato_000\Desktop>set /a "SS"="19"

C:\Users\krato_000\Desktop>if 19 LSS 10 goto day1

C:\Users\krato_000\Desktop>pause
Press any key to continue . . .
Troy Rash
  • 29
  • 4

2 Answers2

2

Please note, batch does not differentiate between %mm%and %MM%. Try this:

:minutes1
set /a min=0
for /f "tokens=1*delims=0" %%a in ("$0%mm%") do set /a min=%%b 2>nul
echo %min%
if %min% equ 0 goto seconds1
Endoro
  • 37,015
  • 8
  • 50
  • 63
1

Perhaps you have a fundamental problem with delims=0. If the value is 00 you will get nothing. So you need to quote some variables

if "%HH%"=="6" goto minutes1

and

if "%MM%"=="" set MM=0 & goto seconds1

and add the first line below

if "%SS%"=="" set SS=0
if %SS% lss 10 goto day1
RGuggisberg
  • 4,630
  • 2
  • 18
  • 27
  • I don't see what you mean by "a missing operand during the execute" – RGuggisberg Jul 12 '13 at 19:32
  • Ok let me say a couple of things. I get the **Missing Operand** error after `:minutes1 for /f "tokens=1*delims=0" %%a in ("$0%mm%") do set /a MM=%%b if %MM% equ 0 goto seconds1` as stated in my op. When i say execute it means the command that is suppose to execute after it finds the correct variable. Also now that i messed with the code some i seem to be getting an extra **Missing Operand** after `:seconds1 for /f "tokens=1*delims=0" %%a in ("$0%ss%") do set /a SS=%%b if %SS% lss 10 goto day1`. To fix the seconds one you say to add `if "%SS%"=="" goto day1`, adding it causes a syntax error. – Troy Rash Jul 12 '13 at 19:46
  • Also changing it to blank `if "%MM%"=="" goto seconds1` seems to not work at all as it tries to see if it is equal to blank rather than 0. Ill edit the post with my log if it helps some. – Troy Rash Jul 12 '13 at 19:49
  • Change if "%MM%"=="" goto seconds1 to if "%MM%"=="" set MM=0 & goto seconds1 as I did above and change if "%SS%"=="" goto day1 to if "%SS%"=="" set SS=0 & goto day1 as I did above. – RGuggisberg Jul 12 '13 at 20:06
  • Then the remaining problem is with $0. That results in an attempt to set MM to a non-numeric value... which can't be done with /a. – RGuggisberg Jul 12 '13 at 20:11
  • Can you remove the $0? What does that do for you? – RGuggisberg Jul 12 '13 at 20:18
  • I tried changing everything you just said to change to try to fix it and i am still getting the missing operand error. – Troy Rash Jul 12 '13 at 21:15