通过批处理文件查找和删除文本中的单词 [英] find and delete a word in a text by batch file
本文介绍了通过批处理文件查找和删除文本中的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我想通过一个批处理文件来查找和删除某些单词,
Hi all I want to find and delete some word by a batch file i tried this:
@Echo OFF
REM Set These Variables
SET "InFile=Unloaded.txt"
SET "OutFile=NowLoaded.txt"
SET "Replace=%r%"
SET "ReplaceWith= "
REM Get Total Lines Number [including empty lines]
FOR /F %%A IN ('TYPE "%InFile%"^|find /v /c ""') DO SET "Till=%%A"
REM Create The OutFile with changes
SETLOCAL EnableDelayedExpansion
<"!InFile!" (
FOR /L %%a IN (1 1 0) DO SET /p "="
FOR /L %%A IN (1 1 %Till%) DO (
SET "line="
SET /P "line="
IF "!line!x" == "x" ( Echo.
) ELSE ( Echo !line:%Replace%=%ReplaceWith%!)
)
)>>"%OutFile%"
ENDLOCAL
,但输出表示回声已关闭,而不是删除. 请帮我谢谢.
but in out put instead of delete that says Echo Is Off. please help me thanks.
推荐答案
Take a look at replacer.bat.You can use it by like this to delete a word in text file:
call replacer.bat text.txt "word" ""
更强大的解决方案是 JREPL.bat 和 FindRepl.bat .
More powerful solutions are JREPL.bat and FindRepl.bat.
这篇关于通过批处理文件查找和删除文本中的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文