Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi all!
I'm a edlin user. I use it very very often in my batch files.The problem is: in edlin, you edit a file with an another file.
(ie: edlin text.dat " command. BUT: edlin uses the ^Z character! And it's interpreted in a batch file as a end-of-file character.
So I can't do a "echo blabla^Zlala > txt.txt" ...>> Is there a way forcing the batch file to ignore ^Z characters?? Maybe something regarding command.com... I don't know. Any help would be welcome!!!! > <<) :-D
email: secret_doom@hotmail.com

I'm not sure I understand what you mean, but here is an edlin batch I use regularly which may be of help.
:: replac.bat
@ECHO off
IF not "%3"=="" GOTO start:help
ECHO.
ECHO %%1 is target file
ECHO %%2 is text to replace
ECHO %%3 is replacement text
ECHO.
ECHO Examples:
ECHO replace test.txt A a : replaces A with a
ECHO replace test.txt color colour : replaces color with colour
ECHO replace test.txt Y N : replaces Y with N
ECHO.
ECHO File to be changed must be in current directory, which
ECHO must be writeable. Filename only; no colon or backslash.
ECHO.
GOTO end:start
ECHO %1 |FIND ":" >nul
IF not errorlevel 1 ECHO colon or backslash not allowed
IF not errorlevel 1 GOTO help
ECHO %1 |FIND "\" >nul
IF not errorlevel 1 ECHO backslash or colon not allowed
IF not errorlevel 1 GOTO help
IF not exist %1 ECHO "%1" not in current directory
IF not exist %1 GOTO help
REM Create an empty script file >%temp%.\replc.scr
FOR %%v in (f100LFF''20 l102 w q) do ECHO %%v>>%temp%.\replc.scr
:: text to be replaced follows immediately after 'R' below
ECHO 1,R%2> %temp%.\part1.txt
:: the following adds two spaces to the front of part1.txt,
:: thus pushing the CR/LF off the end.
:: this works becuase EDLIN.exe ignores leading spaces
IF exist %temp%.\part1.txt DEBUG.exe %temp%.\part1.txt nul
DEL %temp%.\replc.scr > nul
IF exist %temp%.\ctrlz.dat DEL %temp%.\ctrlz.dat > nul
:: this creates a 1 byte file with Ctrl-Z in it
ECHO E| EDLIN.exe /B %temp%.\ctrlz.dat>nul
IF exist %temp%.\part2.txt DEL %temp%.\part2.txt
:: replacement text with follows after 'ECHO ' below
ECHO %3>%temp%.\part2.txt
ECHO e>>%temp%.\part2.txt
COPY /B %temp%.\part1.txt+%temp%.\ctrlz.dat+%temp%.\part2.txt %temp%.\edscr.txt >nul
EDLIN.EXE %1 nul
:: This deletes the EOF character which was added at the end
::
COPY/B/Y %1/A+,, . % Place a '>nul' here to supress screen output%
::DEL %temp%.\%1
DEL %temp%.\ctrlz.dat
DEL %temp%.\edscr.txt
DEL %temp%.\part?.txt:end

Hi. Thanks for your reply.
I didn't understood some parts of it (and it didn't work! -- it stops on debug command)Well, I guess the copy command ("COPY /B %temp%.\part1.txt+%temp%.\ctrlz.dat+%temp%.\part2.txt %temp%.\edscr.txt >nul") gets the text to be replaced (with an 1,r), an ^Z, the replacing text and an e character that commands edlin to exit. Ok, all that to make this line into one file:
1,rstring1^Zstring2
eBut that copy command with + places the contents of files in different lines, like this:
1,rstring1
^Z
string2
eThat's what I didn't get! May you explain me how to make copy command to put contents of files all in the same line?
Thanks again.
Secret_Doom

That replac.bat works perfectly for me.
I hope you're not using NT! Practically
nothing works (or works right) in NT.There are many methods to do what you want,
and I am presently under severe time constraints. My best suggestion is to ask in new:alt.msdos.batch . That is where the batch experts hang out.

Hi, Thanks for pointing me that place.
But I didn't understand that adress!Is that a news adress? Like to use on outlook express or something? I did tryed it, (with server alt.msdos.batch), but didn't work
Please, tell me what does that means, I'm really interested

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

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