批处理文件使用文本文档中的文本替换一个HTML文档中的Word

时间:2014-05-24 18:10:23

标签: batch-file

所以我试图用另一个带有批处理文件的文本文件替换HTML文档(这是代码)中的单词。所以我要说我在HTML文件中有<p> Hello World! </p>。现在我创建一个txt文件,其中包含&#34; goodbye&#34;在里面。现在有一个批处理文件,我想替换&#34;你好&#34;在HTML文件中包含.txt文件中的文本。我尝试了多种在互联网上找到的方法......这是我现在的代码:(也有一些间距错误但是因为stackoverflow因某种原因改变了它):

@echo off
echo seting up session...
for /f "skip=1 delims=*" %%a in (C:\Users\mikebenjcomcast.net\Documents\Noda\origlink.txt) do (
echo %%a >C:\Users\mikebenjcomcast.net\Documents\Noda\medialink.txt
)

for /f "skip=0 delims=*" %%a in (C:\Users\mikebenjcomcast.net\Documents\Noda\command1.txt) do (
echo %%a >>C:\Users\mikebenjcomcast.net\Documents\Noda\session.html
)yy
@echo off &setlocal
set "search=code"
set "replace=%%a"
set "textfile=session.html"
set "newfile=session1.txt"

(for /f "delims=" %%i in ('findstr /n "^" "%textfile%"') do (
    set "line=%%i"
    setlocal enabledelayedexpansion
    set "line=!line:%search%=%replace%!"
    echo(!line!
    endlocal
))>"%newfile%"
type "%newfile%"
echo done! Cleaning things up...
type session1.txt > session.html
start session.html
echo done! Enjoy!

然后它只是打开更新的HTML文件。我也知道中间批次。那么任何帮助呢?它也没有出现错误,但只是在屏幕上快速闪烁并消失(典型的迹象表明你刚刚花了5个小时的批处理程序没有工作......对吗?)。所以请帮助并谢谢你!

0 个答案:

没有答案