Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Ветеран


Сообщения: 27449
Благодарности: 8088

Профиль | Отправить PM | Цитировать


Попробуйте что-то наподобие такого:
Код: Выделить весь код
@echo off
setlocal enableextensions enabledelayedexpansion

set strSourceFileName=%~1
set strTextBefore=%~2
set strTextAfter=%~3
set strFinishFileName=%~4

set strTempFileName=%temp%\tmp%random%.tmp
if exist "%strTempFileName%" del "%strTempFileName%"

if defined strSourceFileName (
    if exist "%strSourceFileName%" (
        for /f "tokens=* delims=" %%i in (!strSourceFileName!) do (
            set strLine=%%i
            echo %strTextBefore%!strLine: =-!%strTextAfter%>>"%strTempFileName%"
        )
        
        if exist "%strFinishFileName%" copy /b "%strTempFileName%"+"%strFinishFileName%" "%strTempFileName%" >nul
        move /y "%strTempFileName%" "%strSourceFileName%" >nul
    )
) else (
    echo Using: %~nx0 ^<File name^> ^<Text before^> ^<Text after^> ^<File name with finish text^>
)

endlocal
exit /b 0
Вызов пакетного файла:
Код: Выделить весь код
mycmd.cmd my.txt "my " you" finishtext.txt
где «finishtext.txt» — текстовый файл, содержащий финальные строки:
Код: Выделить весь код
hello
hi
Это сообщение посчитали полезным следующие участники:

Отправлено: 03:06, 10-07-2009 | #2