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
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 .
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 .
Summary: What does it mean? I have a file which contains the name of various SQL scripts, like... T1.sql; inside these sql scripts i have a commit statement Do you mean that the file contains nothing but the ...
Summary: Does any one know how to use GSAR to search and replace a string with spaces? Say I want to look for the string STRING and I want to replace it with MY STRING. Now I know this is easy GSAR -sSTRING -r...
Summary: For example in a file if I see: "<start> open:my_file.txt open:other_file.text </start>" I'd like to replace it with "<start> {open_me:my_file.txt} {open_me:other_file.text} </start>" I ...