Reading and writing INI files (BATCH)

May 5, 2009 at 18:20:16
Specs: Windows Vista
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 =]


See More: Reading and writing INI files (BATCH)

Report •


#1
May 5, 2009 at 19:34:14
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


Report •
Related Solutions


Ask Question