PC Review Forums Newsgroups Windows 2000 Microsoft Windows 2000 CMD Promt Re: replace line in txt file

Reply

Re: replace line in txt file

 
Thread Tools Rate Thread
Old 03-07-2003, 05:05 PM   #1
Jerold Schulman
Guest
 
Posts: n/a
Default Re: replace line in txt file


On Thu, 3 Jul 2003 16:38:20 +0200, "Black" <radek.behavy@volny.cz> wrote:

>I need a batch file to change specified line in txt file.
>
>I have a file like this
>
>.
>.
>.
>[win32client.dll]
>comdll=sqlws32
>[win32client.ws32]
>serverpath=SCentura,192.168.1.3,2155/*
>.
>.
>.
>
>
>and I need a batch file to replace line
>"serverpath=SCentura,192.168.1.3,2155/*" to
>"serverpath=SCentura,888.888.888.888,2155/*"
>
>Can somebody help me?




@echo off
setlocal
set filename=c:\folder\filename.xxx (the full path to your file)
if exist %TEMP%\replace.tmp del /q %TEMP%\replace.tmp
for /f "Tokens=*" %%a in ('type %filename%') do set line=%%a&call arse
del /q %filename%
copy %TEMP%\replace.tmp %filename%
del /q %TEMP%\replace.tmp
endlocal
goto :EOF
arse
set work=%line:"=%
if /i "%work%" EQU "serverpath=SCentura,192.168.1.3,2155/*" goto replace
ut
@echo %line%>>%TEMP%\replace.tmp
goto :EOF
:replace
set line="serverpath=SCentura,888.888.888.888,2155/*"
goto out

Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off