Page 1 of 1

Another issue

Posted: 11 Sep 2009 09:50
by jreat
I have another batch file I am trying to get working. All I am really trying to do is check a version on a flash drive then update it to the latest version. For some reason it closes before hitting the pause. I have the pause in there to help trouble shoot. Any suggestions?

cls
@echo off
cd sbusb
@echo ----- This is not ready to be used Please close by using RED X ------
@echo.
@echo What drive letter is your flash drive?
set /p dr=
copy %dr%:\version.txt H:\ITM03\Programs\BootDisk\
type version.txt> %ver%
pause
if '%ver%'=='378' goto 379
if '%ver%'=='379' goto 380
if '%ver%'=='380' goto 381
if '%ver%'=='381' goto 382
if '%ver%'=='382' goto 383
if '%ver%'=='383' goto 384
if '%ver%'=='384' goto 385
if '%ver%'=='385' goto 386
if '%ver%'=='386' goto 387
if '%ver%'=='387' goto 388
if '%ver%'=='388' goto 389
if '%ver%'=='389' goto end
:378
:379

and so on

Posted: 11 Sep 2009 10:38
by avery_larry
%ver% is not defined.

Posted: 11 Sep 2009 10:39
by avery_larry
I think you want this:

for /f %%a in (version.txt) do set ver=%%a


not this

type version.txt>%ver%

Posted: 11 Sep 2009 11:06
by jreat
what does the %%a mean / do?

So I just removed the % signs and it works. The type is setting ver. Or at least seems to be.

type version.txt> ver

Posted: 11 Sep 2009 12:37
by jreat
ok so it is closer. The program stays open but it is not going to the correct spot. it runs 378 then 379. I want it to jump to the correct version. I tried what you suggested Larry but that did not work either :(

Posted: 11 Sep 2009 14:37
by avery_larry
jreat wrote:what does the %%a mean / do?

http://ss64.com/nt/for.html
So I just removed the % signs and it works.
It doesn't work -- it just continues on but doesn't do what you want.
The type is setting ver. Or at least seems to be.

type version.txt> ver
No, it's not setting a variable. It's redirecting the output of the type command into a file called "ver".

You probably have to add the drive letter to make it work:

Code: Select all

for /f %%a in (%dr%:\version.txt) do set "ver=%%a"


To see what ver gets set to you can:

echo %ver%

If it's not working, you can remove the @echo off and perhaps see more of what's happening. Otherwise you may have to post your version.txt file to see if it's the problem.

Posted: 14 Sep 2009 09:51
by jreat
That works great now. Thank you so much for your help. And thank you for the link that describes what they do.