Solved Batch file replace lines in.txt

May 27, 2011 at 06:25:58
Specs: Windows 7
I want users to be able to enter what they want to replace in line 2. I will also have another one that will replace what is in line 4. Thanks in advance.

See More: Batch file replace lines in.txt

Report •


#1
May 28, 2011 at 04:59:23
✔ Best Answer
:: ==========================================
::
:: 0SKS0.bat Sat 28-05-2011 18:52:30.45
@echo off > newfile & setLocal enableDELAYedeXpansioN

set /p A=replace?
set /p B=with?

set N=
for /f "tokens=* delims= " %%a in (myfile) do (
set /a N+=1
set S=%%a
if !N! equ 2 set S=!S:%A%=%B%!
echo.!S!
) >> newfile


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
May 28, 2011 at 05:09:30
Thanks you!

Report •
Related Solutions


Ask Question