Hi All,
First time poster. I hope you might be able to help me on this please? I need to write a batch to edit an ini file on a remote CPU running XP embedded.
I need to edit an ini file on one line but leave the other lines intact with no changes.
I need to edit line 2
SCHEME=3|00|0|0|
and leave the rest of the text
PrintPause=00
SCHEME=3|10|0|0|
TL_IP=xxxx|TL_PORT=xxxx|
ULOG_IP=xxxx|ULOG_PORT=xxxx|
UDP_PORT=xxxx|
TimeFromServer|TIME_PORT=xxxx|
xxxx_COMPORT=COM5|
xxxx_COMPORT=COM3|
DeclineReInitTran|
VolumeControl|
GPS_COMPORT=COM6|
MediaUDP_IP=xxxxxxxx|
MediaUDP_Port=xxxxxx|
Is anyone able to help me please
Writing a batch file to amend .ini
Moderator: DosItHelp
Re: Writing a batch file to amend .ini
Here is a general substitution exampleusing an excellent tool described here:http://www.dostips.com/forum/viewtopic.php?f=3&t=4697
If you need more help specify the text to which you want it changed.
John A.
Code: Select all
< theFile.txt FindRepl "ACSD" "XYZ"
If you need more help specify the text to which you want it changed.
John A.
Re: Writing a batch file to amend .ini
I missed the subtle change. Here is some code:After adjusting to the name of your particular .ini file, that leaves you with two files. You'll have to handle the authorizations, backups, renames and deletes from there.
John A.
Code: Select all
@Echo Off
SetLOCAL EnableDelayedExpansion
Echo.input:
Type Some_Old.ini
set "1st="
(for /F "delims=" %%a in ('Type Some_Old.ini') do (
If /i ".%%a" EQU ".SCHEME=3|10|0|0|" Set "1st=1"
If ".!1st!" NEQ ".1" echo %%a
)
)>Some_New.ini
Echo.
>>Some_New.ini Echo.SCHEME=3^|00^|0^|0^|
set "1st="
(for /F "delims=" %%a in ('Type Some_Old.ini') do (
If ".!1st!" EQU ".1" echo %%a
If /i ".%%a" EQU ".SCHEME=3|10|0|0|" Set "1st=1"
)
)>>Some_New.ini
Echo.output:
Type Some_New.ini
Exit /b
John A.
-
- Posts: 2
- Joined: 01 Feb 2016 08:40
Re: Writing a batch file to amend .ini
Sorry its taken me forever to reply! thank you. Ill go check it out.
Re: Writing a batch file to amend .ini
Raindancer wrote:Sorry its taken me forever to reply! thank you. Ill go check it out.
It's nice that you came back to reply.
It's even nicer if you check it out first and come back and say "thank you"