Batch file to edit a .config file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mtwa
Posts: 1
Joined: 19 Aug 2019 12:17

Batch file to edit a .config file

#1 Post by mtwa » 19 Aug 2019 12:29

I have a .config file that has a list of IP addresses, these IP addresses need updating. I need to update the config file on 115 computers.

I was hoping this could be done in a bat file that will delete the ip addresses already in the file and replaces them
For example it does something along the lines of

in the file c:/settings.config
between the text
<sites default="127.0.0.1">
and
</sites>
delete and replace with
<site ipAddress="192.168.0.1" name="PC1" port="1001" number="1001"/>
<site ipAddress="192.168.0.2" name="PC2" port="1001" number="1002"/>
<site ipAddress="192.168.0.3" name="PC3" port="1001" number="1003"/>
<site ipAddress="192.168.0.4" name="PC4" port="1001" number="1004"/>
<site ipAddress="192.168.0.5" name="PC5" port="1001" number="1005"/>
<site ipAddress="192.168.0.6" name="PC6" port="1001" number="1006"/>

penpen
Expert
Posts: 1714
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Batch file to edit a .config file

#2 Post by penpen » 25 Aug 2019 13:06

Depending on the content of your file you coudl either use Dave's JREPL.BAT:

Code: Select all

https://www.dostips.com/forum/viewtopic.php?t=6044
--- or you could use xslt to change the xml data; example:
viewtopic.php?p=32941#p32941


penpen

Post Reply