Solved Batch file to edit text file ?

Bitsa
April 18, 2006 at 05:03:04
Specs: MS-DOS-6.22, more than enough
Hi,

I'm looking for a simple batch file which will edit "protocol.ini" (see below) for me and replace one number with another. I want to be able to replace the last segment of the line "IPAddr=[172.16.15.201]" that is, I want to replace the 201 with some other 3 digit number.

A batch file which would accept a parameter would be great

e.g
C:\file.bat 202
would find and replace the 201 with 202. (it will always start off as 201).


Thanks

Mike


Protocol.ini....

[network.setup]
version=0x3100
netcard=NIC,1,NIC
transport=nts$ntst2,NTS$NTST2
transport=ibm$netbeui,IBM$NETBEUI
lana0=NIC,1,ibm$netbeui
lana1=NIC,1,nts$ntst2

[NTS$NTST2]
DefaultDomain=ptstaff
DNSaddr=[172.16.1.12]
GatewayAddr=[172.16.15.1]
NetSubNetMask=[255.255.255.0]
IPAddr=[172.16.15.201]
DriverName=ntsts$
VCs=16
VCReceiveLarge=6
VCSends=6
RcvWindow=2920
UseMemory=UMB
BINDINGS=NIC
LANABASE=1

[protman]
DriverName=PROTMAN$
PRIORITY=ibm$netbeui

[IBM$NETBEUI]
DriverName=netbeui$
SESSIONS=20
NCBS=20
BINDINGS=NIC
LANABASE=0

[nic]
drivername = E100B$


See More: Batch file to edit text file ?

Report •


#1
April 18, 2006 at 05:40:11
✔ Best Answer
Hi Mike,

Getting it done with DOS 6.22 tools will be pretty hard going.

If you can accept a 3rd party util, get Change

Use this one line BAT:

change Protocol.ini "172.16.15.201" "172.16.15.%1"



=====================================
If at first you don't succeed, you're about average.

M2Go



Report •

#2
April 18, 2006 at 06:09:30
Many thanks M2Go, could be EXACTLY what I'm looking for :-) I'll d/l and give it a whirl.

ATB

Mike


Report •

#3
April 19, 2006 at 02:43:29
Thanks again M2Go, it's perfect. I've downloaded change.com and incorporated it into a 2 line batch file (tweak.bat) so it will tweak the IP address in protocol.ini and the computername in network.ini when given a parameter.

C:\tweak 202

change net\protocol.ini "201" "%1"
change net\network.ini "computername=images" "computername=images%1"

-


Report •

Related Solutions

#4
April 19, 2006 at 03:09:08
Hi Mike,

Looks like you got the hang of it pretty quick.

For future use, keep in mind that your first line will replace EVERY instance of 201, which is not an issue with this protocol.inf but could be with other files, if they happened to contain something like:

dns=201.x.x.x


=====================================
If at first you don't succeed, you're about average.

M2Go



Report •

#5
April 20, 2006 at 01:46:40
Thanks again M2Go. I carefully checked the contents of protocol.ini and network.ini before I ran the batch file, just in case there were other entries which would change :-)

I'm sure I'm going to find many other uses for change.com, a very handy little prog.

ATB

Mike


Report •

#6
May 15, 2006 at 12:31:06
Hi,
I have just downloaded the Change.com program and I'm looking for more info.

I have a CSV file where two of my columns have the same name. I would like to use the program so that every week when the CSV is downloaded, change would open the file and chane the name of only one of the two columns. Can it be done and how?

Thanks for your help.


Report •

#7
May 15, 2006 at 16:33:49
Hi Frenchie,

Paste in the exact [I assume first row] text and we'll checkit it out. Be aware that CHANGE.COM is limited to files of up to about 30KB.


If at first you don't succeed, you're about average.

M2


Report •


Ask Question