Computing.Net > Forums > Disk Operating System > please help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

please help

Reply to Message Icon

Name: sami-bami
Date: July 29, 2003 at 10:09:50 Pacific
OS: win xp
CPU/Ram: 256
Comment:

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




Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: July 29, 2003 at 21:00:14 Pacific
Reply:

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

_____________________________________________________________


0

Response Number 2
Name: Secret_Doom
Date: July 29, 2003 at 21:05:16 Pacific
Reply:

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

______________________________________________________________________


0

Response Number 3
Name: sami-bami
Date: July 30, 2003 at 03:37:15 Pacific
Reply:

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.


0

Response Number 4
Name: Secret_Doom
Date: July 30, 2003 at 10:09:55 Pacific
Reply:

This is it:

set mesg=%mesg:~,-1%

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 5
Name: sami-bami
Date: July 31, 2003 at 10:55:24 Pacific
Reply:

Secret_Doom

thank you you helped a lot.

:-)


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon

automate what a menu do!? Check Install on multiple...



Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: please help

please help no system hard drive wont stop spinning at startup www.computing.net/answers/dos/please-help-no-system-hard-drive-wont-stop-spinning-at-startup/3475.html

Dos Error ...Please Help www.computing.net/answers/dos/dos-error-please-help/695.html

unformat? please help www.computing.net/answers/dos/unformat-please-help/8459.html