Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hi
i need to find a line from a text file and put it into a variable.this doesn't work:
set fip= find "[1]" type o.txt

Use this, instead:
find "[1]" < o.txt > %temp%.\$
for /F "tokens=*" %%S in (%temp%.\$) do set fip=%%S
del %temp%.\$Or this:
for /F "tokens=*" %%S in (FINDSTR "[1]" o.txt) do set fip=%%S
Just be aware that the behavior of FIND and FINDSTR are very different in some cases. For more information, type "FINDSTR/?" and "FOR/?" on the command prompt.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br_____________________________________________________________

The second method is wrong, sorry. This is it:
for /F "tokens=*" %%S in ('FINDSTR "[1]" o.txt') do set fip=%%S
And you can yet shrink that first method (the one using FIND) to this:
for /F "skip=2 tokens=*" %%S in ('FIND "[1]" o.txt') do set fip=%%S
This last one is actually the method/syntax I recommend. I shouldn't even have mentioned the other ones.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br______________________________________________________________________

Secret_Doom tank again :-)
last thing i need for my project is to delete the last character that is in the variable(that was takken for the .txt file).
i know that: set mesg=%mesg:~3%
will delete the 3 first character,but how can i delete only the last character from the variable.tanx again.

This is it:
set mesg=%mesg:~,-1%
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
automate what a menu do!?
|
Check Install on multiple...
|

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