问题
I have a huge file approx 100 mb to 500 mb, it take more time to open it and I cannot change it also due to slow response in Notepad or notepad++.
I have requirement to replace only REF Number and this is only one time in the file.
Can I have a Batch file/ Script in Command prompt so that I can replace the text?
Regards and Thx.
回答1:
@echo off
set "toreplace=REF"
for /f "tokens=* delims= " %%a in (yourfile.txt) do (
set "line=%%a"
setlocal enabledelayedexpansion
set "line=!line:%toreplace%=!"
echo !line! >>newfile.txt
)
this code deletes all REF
strings from yourfile.txt
and outputs it to newfile.txt
.
not my code.
来源:https://stackoverflow.com/questions/42052039/search-and-replace-text-in-a-txt-file-by-a-batch-file-in-windows