1
我創建了一個.cmd文件,該文件以文件名作爲參數,然後它要求字符串查找,然後字符串進行替換。在.txt文件中使用.cmd文件查找並替換
所需出來把
findthis應該從replacewith給定的文件被替換,但它不工作
以下是我已經嘗試代碼..
@echo off
setlocal enabledelayedexpansion
if not exist "%1" (echo this file does not exist...)&goto :eof
set /p findthis=find this text string:
set /p replacewith=and replace it with this:
for /f "tokens=*" %%a in (%1) do (
set write=%%a
if %%a==%findthis% set write=%replacewith%
echo !write!
echo !write! >>%~n1.replaced%~x1
)
感謝