Computing.Net > Forums > Programming > search and replace a string in ini

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

search and replace a string in ini

Reply to Message Icon

Name: sonali
Date: August 26, 2008 at 23:24:34 Pacific
OS: windowsxp
CPU/Ram: dell
Product: microsoft
Comment:

Hi! i m new to batch programing. I want to make a batch file which will search for a particular string in a ini file and replace it with a another string .

Can anyone help me.
Thanks in advance.

Hi! i m new to batch programing. I want to make a batch file which will search for a particular string in a ini file and replace it with a another string .

Can anyone help me.
Thanks in advance.



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: August 26, 2008 at 23:46:52 Pacific
Reply:

@echo off > newfile
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (my.ini) do (
set str=%%a
set str=!str:oldtext=newtext!
echo !str! >> newfile
)


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

M2


0

Response Number 2
Name: Judago
Date: August 26, 2008 at 23:58:20 Pacific
Reply:

I haven't thought of any way to do this yet but dosen't the above just set a variable of the old text, then change the variable to the new text then append it to the ini, which is otherwise unchanged?


0

Response Number 3
Name: Mechanix2Go
Date: August 27, 2008 at 01:25:00 Pacific
Reply:

It writes to newfile.


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

M2


0

Response Number 4
Name: Judago
Date: August 27, 2008 at 01:57:29 Pacific
Reply:

sorry you are very much right, that's what I get for thinking about three things at once.


0

Response Number 5
Name: sonali
Date: August 28, 2008 at 02:45:27 Pacific
Reply:


It works!!
Thanks a lot.

Hi! i m new to batch programing. I want to make a batch file which will search for a particular string in a ini file and replace it with a another string .

Can anyone help me.
Thanks in advance.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: search and replace a string in ini

Find and replace a string in a file www.computing.net/answers/programming/find-and-replace-a-string-in-a-file/19034.html

GSAR to find and replace www.computing.net/answers/programming/gsar-to-find-and-replace/17186.html

Perl search and replace www.computing.net/answers/programming/perl-search-and-replace/14586.html