Batch File to check value of variable

Score
0
Vote Up
February 1, 2012 at 08:56:46 Pacific
Specs: Windows XP

Using this batch file that I found here:
@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (sessopen.log) do (
set var=%%a
)
echo !var!


I get this result from my file I'm looking at:

02/01/12 10:00:00 AM Session 3 is closed

I want to compare the last word of that file. The word will either be Open or Closed. Everything else isn't necessary for me to look at. I'm just wanting to check either Open or Closed.


So above batch file runs then,

If last word is Open goto something (i can handle)
if last word is Closed goto something


How do I do that?

The echo command in the batch file will not be used, just in there for testing atm.

Thanks in advance.


Reply ↓  Report •


#1
Vote Down
Score
0
Vote Up
February 1, 2012 at 09:20:04 Pacific

@echo off
for /F "tokens=7" %%a in (sessopen.log) do set var=%%a
if /I "%var%"=="closed" (goto :CLOSED) else (goto :OPEN)
goto :EOF

:CLOSED
...
goto :EOF

:OPEN
...
goto :EOF


Reply ↓  Report •

#2
Vote Down
Score
0
Vote Up
February 1, 2012 at 09:34:33 Pacific

Thanks for the help.


Reply ↓  Report •

Reply to Message Icon Start New Discussion
Related Posts

« [Solved] Continue with next file i... FTP download »