Computing.Net > Forums > Programming > Reading and writing INI files (BATCH)

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.

Reading and writing INI files (BATCH)

Reply to Message Icon

Name: willz
Date: May 5, 2009 at 18:20:16 Pacific
OS: Windows Vista
Subcategory: Batch
Comment:

ok let's say I have an INI file and this is the
contents

[you]
name=george


now... how ddo I create a batch to read this in
and put

echo hello %name% how are you?

plz answer =]



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: May 5, 2009 at 19:34:14 Pacific
Reply:

if you foresee that you are going to do such things often in future, you can use a programming language that provides modules to parse ini files easily. eg here's a Python script

import ConfigParser
config = ConfigParser.ConfigParser()
config.read("file")
for section in config.sections():
    if section == "you":
        for option in config.options(section):
            print "hello " ,config.get(section, option).split("=")[-1]

save the above as test.py and on command prompt:
c:\test> python test.py
hello  george


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 Programming Forum Home


Sponsored links

Ads by Google


Results for: Reading and writing INI files (BATCH)

VC++ - Read INI Files www.computing.net/answers/programming/vc-read-ini-files/15763.html

vb read and write file www.computing.net/answers/programming/vb-read-and-write-file/6672.html

how to read and write the disk www.computing.net/answers/programming/how-to-read-and-write-the-disk-/11804.html