How replace a word in a text file using a .bat file?
本问题已经有最佳答案,请猛点这里访问。
我不熟悉BAT脚本,所以我计划在名为"samplefile.txt"的文本文件中更改一个单词。
有人能帮我吗?谢谢斯:
如本例所示,使用下面的批处理文件,将
1 | changefile.bat"apple""orange""file.txt">"newfile.txt" |
检查DOS批次-查找并替换:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | @echo off REM -- Prepare the Command Processor -- SETLOCAL ENABLEEXTENSIONS SETLOCAL DISABLEDELAYEDEXPANSION ::BatchSubstitude - parses a File line by line and replaces a substring" ::syntax: BatchSubstitude.bat OldStr NewStr File :: OldStr [in] - string to be replaced :: NewStr [in] - string to replace with :: File [in] - file to be parsed :$changed 20100115 :$source http://www.dostips.com if"%~1"=="" findstr"^::""%~f0"&GOTO:EOF for /f"tokens=1,* delims=]" %%A in ('"type %3|find /n /v"""') do ( set"line=%%B" if defined line ( call set"line=echo.%%line:%~1=%~2%%" for /f"delims=" %%X in ('"echo."%%line%%""') do %%~X ) ELSE echo. ) |