dbohdan / initool

Manipulate INI files from the command line

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to update multiple values in an ini file

faridskyman opened this issue · comments

i tried, to update just one value it works
but i want to update multiple values in an ini file, it seems to overwrite my previous value..
i guess this works for existing values and new value, it can only add one?

It sounds like you are not copying the updated file back over the original after every step. Initool doesn't modify the file, so you must do it like in README.md#examples. Tell me your OS and the exact commands you are using.

hi @dbohdan here is my commands

set toolPath=C:\Tools
set demoPath=C:\zspace\App
set demofile=mlib.ini
set demofile2=mlib2.ini
set demofilename=mlib2

rem show content of the ini file
%toolPath%\initool get %demoPath%\%demofile%

rem edit Cflags value
%toolPath%\initool set %demoPath%\%demofile% default Cflags 1 > %demoPath%\%demofile2%
rem edit Libs  value
%toolPath%\initool set %demoPath%\%demofile% default Libs demoMode > %demoPath%\%demofile2%

this is the content of my file mlib.ini

[meta]
Name = mlib
Description = Math library used with this version of numpy
Version = 1.0

[default]
Libs=
Cflags=

[msvc]
Libs=m.lib
Cflags=

I see. Your batch file reads the same INI file twice. This is why the new value of Cflags is lost.

Change the last line of the batch file

%toolPath%\initool set %demoPath%\%demofile% default Libs demoMode > %demoPath%\%demofile2%

to

%toolPath%\initool set %demoPath%\%demofile2% default Libs demoMode > %demoPath%\%demofile%

so you read the second file and write back to the first.

I am closing the issue due to a lack of activity. Go ahead and reopen if you have more questions.