PC Review


Reply
Thread Tools Rate Thread

Re: replace line in txt file

 
 
Jerold Schulman
Guest
Posts: n/a
 
      3rd Jul 2003
On Thu, 3 Jul 2003 16:38:20 +0200, "Black" <(E-Mail Removed)> 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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
is there any command line program do has the ability to find &replace string in a file twicethinking@gmail.com Microsoft Windows 2000 CMD Promt 1 12th Dec 2008 07:28 AM
How to store/read listbox items in a text file line by line (with line break) ? kimiraikkonen Microsoft VB .NET 6 2nd Nov 2007 06:27 PM
replace new line =?Utf-8?B?QmlsbCBnb2xk?= Microsoft Frontpage 2 2nd Jan 2006 05:23 PM
Fast file access reading text file line per line Volker Jobst Microsoft VB .NET 4 23rd Jun 2004 12:23 PM
Replace methode, Replace Function, Stringbuilder replace, Regex Replace, Split Cor Microsoft VB .NET 4 1st Mar 2004 03:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:35 PM.