Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I’m trying to making a batch file that replaces a word with another in a file(s!) that containing the word. By using Edlin program.
And to use edlin so req. it ^Z (Ctrl+Z) as a breaker between old text and the new text, but that’s no problem. It’s the end-of-line char that’s the problem when I use echo!This batch is meant to run on a windows 2000 machine.
Exec:
Batchfile searchfile oldtext newtextZ file is containing the end-of-file char. (^Z) so I can create the 1Roldtext^Znewtext line to use with edlin.
@echo off
Setlocal
echo %2>tmp #must remove the end-of-line (CR/LR) from this file in order for this to work.
echo %3>tmp1
copy /b tmp + z + tmp1 edlin.rep >Nul
echo E >> edlin.rep #in order to quit edlin.
For /f “” %%a IN (‘dir /s %1 ’) DO For /f “” %%b IN (‘find “%2” %%a’) DO edlin %%b <edlin.rep &del %%b.bak #Not finished...
del tmp&del tmp1&del edlin.repEdlin.rep #with end-of-line...
1Roldtext
^Znewtext
EMust be: then it will work.
1Roldtext^Znewtext
EAnd I don’t know how to work with Debug so I’m stuck and I’m out of ideas. Please help me!

This might help, it requires Debug but it's simple to create.
Paste the text below into notepad not the
dividing lines ie ------- and save, name as oneline.txt.
Go to the command prompt and type
debug < oneline.txt to create oneline.comUse this syntax in you batch file.
It works like echo but there is no CR/LR at the end.oneline Copy to > temp.txt
echo Filename >> temp.txttemp.txt now containts "Copy to Filename"
on one line.
n oneline.com
a 100
mov ah,2
mov si,82
mov,dl,[si]
cmp dl,d
jz 113
mov ah,2
int 21
inc si
jmp 105
mov ah,4c
int 21r cx
17
w
q
--------------

dtech10,
That's pretty slick
I'm not sure exactly what Saldor needs, but I thought it was to replace one word with another in a file.
If so, I recommend CHANGE.COM from PC Magazine for files up to about 30K, and CHANGE.exe from Bruce Guthrie for files of any size.
HTH
M2

![]() |
![]() |
![]() |

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