How to make a batch file that reads a string?

January 19, 2010 at 18:13:35
Specs: Windows XP
I've made this batch file:

@ECHO OFF
copy c:\tesi\vectorSVM.dat c:\tesi\libsvm\vectorSVM.dat
cd c:\tesi\libsvm\
svm-predict vectorSVM.dat trainingdataSVM3.dat.model vectorSVM.predict
copy c:\tesi\libsvm\vectorSVM.predict c:\tesi\vectorSVM.predict
del vectorSVM.predict
cd c:\tesi\

I need it to read the string created in vectorSVM.predict, if it's 1 it shoud be printed a text, if it's -1 another. How can I do it?


See More: How to make a batch file that reads a string?

Report •


#1
January 19, 2010 at 23:04:30
Try this assuming VectorSVM.predict will only ever contain a value of 1 or -1:

Set /p var=<vectorSVM.predict
if %var% gtr 0 echo this text
if %var% lss 0 echo that text


Report •

#2
January 19, 2010 at 23:19:44
the first line not my idear, i stole it from Mechanix2go (and this assuming you only want the first line of the file):
set /p xx=<:\tesi\vectorSVM.predict
if "%xx%"="-1" goto :neg
if "%xx%"=1 goto :pos
echo ?????:xx is [%xx%]
goto :eof
:neg
echo this is the negative output
goto :eof
:pos
echo this is the positive output

(edit)
LL! talk about a "photo finish"!
i keep getting deja vu all over again,
groundhog day is coming up...


Report •

Related Solutions


Ask Question