Solved Changing one value in an .ini file

April 19, 2018 at 05:29:11
Specs: Windows 7
Good morning/afternoon/evening,

I have one .ini file that needs to be quickly modified by use of a batch script if anyone is so inclined to help.

Filename is called BlueTalk.ini and the only value I want to change is TimeToLive=1 and This value needs to be changed to TimeToLive=0

EDIT: path to file is %Appdata%\Roaming\value1\value2\BlueTalk.ini

Thank you for your time and help.

message edited by Skypivot


See More: Changing one value in an .ini file

Report •

#1
April 19, 2018 at 06:03:46
✔ Best Answer
this will look for the line containing "TimeToLive=0"

echo everything before it into file:Output.ini
echo a new line line (TimeToLive=1) to output.ini
echo everything after TimeToLive=0 into output.ini

result: a copy of your file with only value 0 changed to 1, no need for a backup

::start of test.bat
@echo off
pushd "%Appdata%\Roaming\value1\value2"
set "file=BlueTalk.ini"
set "outputfile=output.ini"
for /f "tokens=1 delims=[]" %%a in ('type "%file%" ^| find /N "TimeToLive=0"') do set linenumber=%%a
for /f "tokens=1,2* delims=[]" %%a in ('type "%file%" ^| find /N /v ""') do if %%a LSS %linenumber% echo %%b>>%outputfile%
echo TimeToLive=1 >>%outputfile%
for /f "tokens=1,2* delims=[]" %%a in ('type "%file%" ^| find /N /v ""') do if %%a GTR %linenumber% echo %%b>>%outputfile%
exit/b
::end of test.bat

i5-6600K[delid]@4.9GHz/4.5GHz@1.42v LLC=6 | 2x4GB Crucial-DDR4-2133CL15@14-14-14-30 1T 2800MHz@1.37v
ASUS Z170K | Samsung 250GB SSD 850 EVO
MSI Armor RX 570 4GB@1440Mhz core@1.268v/1920MHz memo


Report •

#2
April 19, 2018 at 08:35:20
But perhaps make a copy of the file as first and change/edit that copy. That way you have the original version should you need it were anything to go awry in your editing?

Always wise to have a copy of unedited content somewhere safe...?


Report •

#3
April 19, 2018 at 08:41:57
the original is only read, no changed are made to BlueTalk.ini
instead it echos the contents to Output.ini
ofcourse i can change it so it overwrites BlueTalk.ini, but i didnt feel like doing that.

i5-6600K[delid]@4.9GHz/4.5GHz@1.42v LLC=6 | 2x4GB Crucial-DDR4-2133CL15@14-14-14-30 1T 2800MHz@1.37v
MSI Armor RX 570 4GB@1440Mhz core@1.268v/1920MHz memory@1.0v BiosModded


Report •
Related Solutions


Ask Question