Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi All,
I have a text file say, tmp.txt which is having an unique entry at the end of the file "Status:Running" or "Status:Stopped".
Now through a Batch ,I want to read the word after ":" in this file tmp.txt.
And then store that word into a varaible say ,"abc" and check condition,If abc=="Running " goto :Run
and if abc =="Stopped" goto :Stop
Can anybody help me?
Thanks in advance.
Hi! i m new to batch programing. I want to make a batch file which will search for a particular string in a ini file and replace it with a another string .
Can anyone help me.
Thanks in advance.

I want to clarify a couple of things
1.You say you say it is a "unique" entry, will it be the only line that starts with "status:"?
2.You say "at the end of the file", would it always be in a fixed position like the last or second last line?
3.Is there any posibility that there will be anything else on the line after "status:*state*"?

Looks like Razor2.3 has it nailed.
Be careful with your use of spaces or you'll wind up tearing your hair out.
If abc=="Running " goto :Run
and if abc =="Stopped" goto :StopYou don't want to copare *abc* you want to compare the VALUE.
if !abc!==blabla
Better yet:
goto :!abc!
:running
: do bla
goto :eof:stopped
: do bla2
=====================================
If at first you don't succeed, you're about average.M2

For making it more clear,
I want to read the String after "Status:" which will be always the last line of the file.Hi! i m new to batch programing. I want to make a batch file which will search for a particular string in a ini file and replace it with a another string .
Can anyone help me.
Thanks in advance.

Does that pertain to this thread?
=====================================
If at first you don't succeed, you're about average.M2

I just hate using find....
On my computer the below is marginally faster than using find on a large text file (36880 lines, 3.8mb).Only if I could get it into one line.....
SET LINECNT=0
FOR /F "SKIP=1" %%G IN (YOURTEXTFILE.TXT) DO SET /A LINECNT+=1
FOR /F "SKIP=%LINECNT% TOKENS=2 DELIMS=: " %%H IN (YOURTEXTFILE.TXT) DO SET YOURVAR=%%H[Edit: I have a knack for overcomplicating things]
FOR /F "TOKENS=2 DELIMS=: " %%H IN (YOURTEXTFILE.TXT) DO SET YOURVAR=%%H

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |