WEB开发网
开发学院软件开发Shell 批处理实现文本替换 阅读

批处理实现文本替换

 2012-05-19 07:50:30 来源:WEB开发网   
核心提示:水蛇.txt的内容为:正在处理:C:\Program Files\Internet Explorer\IEXPLORE.EXE 正在处理:C:\Program Files\Internet Explorer\Connection Wizard\icwconn.dll 正在处理:C:\Program Files\Inte
水蛇.txt的内容为:

正在处理:C:\Program Files\Internet Explorer\IEXPLORE.EXE 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\icwconn.dll 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\icwconn1.exe 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\icwconn2.exe 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\icwdl.dll 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\icwhelp.dll 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\icwip.dun 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\icwres.dll 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\icwrmind.exe 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\icwtutor.exe 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\icwutil.dll 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\icwx25a.dun 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\icwx25b.dun 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\icwx25c.dun 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\inetwiz.exe 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\isignup.exe 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\msicw.isp 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\msn.isp 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\phone.icw 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\phone.ver 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\state.icw 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\support.icw 
正在处理:C:\Program Files\Internet Explorer\Connection Wizard\trialoc.dll 
正在处理:C:\Program Files\Internet Explorer\HMMAPI.DLL 
正在处理:C:\Program Files\Internet Explorer\iedw.exe 
正在处理:C:\Program Files\Internet Explorer\IEXPLORE.EXE 
正在处理:C:\Program Files\Internet Explorer\SIGNUP\INSTALL.INS

执行批处理后得到

水蛇1.txt     内容为

del /f /q "C:\Program Files\Internet Explorer\IEXPLORE.EXE "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\icwconn.dll "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\icwconn1.exe "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\icwconn2.exe "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\icwdl.dll "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\icwhelp.dll "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\icwip.dun "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\icwres.dll "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\icwrmind.exe "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\icwtutor.exe "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\icwutil.dll "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\icwx25a.dun "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\icwx25b.dun "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\icwx25c.dun "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\inetwiz.exe "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\isignup.exe "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\msicw.isp "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\msn.isp "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\phone.icw "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\phone.ver "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\state.icw "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\support.icw "
del /f /q "C:\Program Files\Internet Explorer\Connection Wizard\trialoc.dll "
del /f /q "C:\Program Files\Internet Explorer\HMMAPI.DLL "
del /f /q "C:\Program Files\Internet Explorer\iedw.exe "
del /f /q "C:\Program Files\Internet Explorer\IEXPLORE.EXE "
del /f /q "C:\Program Files\Internet Explorer\SIGNUP\INSTALL.INS "
setlocal ENABLEDELAYEDEXPANSION
for /f "tokens=*" %%i in (水蛇.txt) do (
set var=%%i
set "var=!var:正在处理:=del /f /q "!""
echo !var!>>水蛇1.txt
)

Tags:批处理 实现 文本

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接