Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I want to find a string from a file and replace a string using a bat file. I have tried with findstr to find a string but not sure how to replace the string.
For example, in a file test.bat
string is HOST_NAME=a
I want to replace this string value as HOST_NAME=b.Thanks.

It's difficult, at best, witha a BAT, even in NT/XP.
I use either CHANGE.COM for text files up to about 32KB, or CHANGE.exe for files of any type/size.
M2
If at first you don't succeed, you're about average.

Hi M2,
Thanks for ur help.
Please let me know how to use this Change.com, what all parameters I need to pass?
Thanks.

Hi,
I guess I should put a readme in the ZIP. [doh]
The syntax is as follows:
change.com filename.ext "old string" "new string"
The new and old strings must be doublequoted and separated by EXACTLY ONE space.
So, for your example:
change.com test.bat "HOST_NAME=a" "HOST_NAME=b"
That's all one line, though it may get wrapped by the forum.
HTH
M2
If at first you don't succeed, you're about average.

![]() |
folder permissions
|
Search in Windows Explore...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |