Computing.Net > Forums > Windows XP > Batch file parsing a text file

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.

Batch file parsing a text file

Reply to Message Icon

Name: GEAK
Date: February 18, 2009 at 16:23:19 Pacific
OS: Windows XP
Subcategory: General
Comment:

I currently have a batch file with the following lines at or near the beginning:

SET TargetIP=www.somesite.com
SET PingCount=10

Rather than have the user modify my batch file, I'd like to have the values "www.somesite.com" and "10" in a text file (call it "variables.txt") which the batch file would read. Is this possible?



Sponsored Link
Ads by Google

Response Number 1
Name: Valerie (by Garibaldi)
Date: February 18, 2009 at 23:58:53 Pacific
Reply:

Because it's just a 2-line text file here's a real lazy way...

:: Code begins....
@echo off
cls

for /f "delims==" %%A in (variables.txt) do (
     set TargetIP=%%A & goto next
)

:next

for /f "delims==" %%A in (variables.txt) do (
     set PingCount=%%A
)

echo TargetIP=%TargetIP%    PingCount=%PingCount%

:: Code ends....



0
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Batch file parsing a text file

Batch File Parsing a text file www.computing.net/answers/windows-xp/batch-file-parsing-a-text-file-/151425.html

parsing through a text file using a batch www.computing.net/answers/windows-xp/parsing-through-a-text-file-using-a-batch-/180355.html

Batch file to edit text file www.computing.net/answers/windows-xp/batch-file-to-edit-text-file/156973.html