如何替换同一目录下多个txt(记事本)中的特定字符,求批处理或者其他工具
2011-05-18
展开全部
5分也太少了吧,虽然我对悬赏分 没啥兴趣。
@echo off
set str1=原字符
set str2=替换为
set ext=*.txt
echo file=wscript.arguments(0)>LSD.vbs
echo set fso=createobject("scripting.filesystemobject")>>LSD.vbs
echo set fil=fso.opentextfile(file)>>LSD.vbs
echo s=fil.readall>>LSD.vbs
echo fil.close>>LSD.vbs
echo set fi=fso.opentextfile(file,2)>>LSD.vbs
echo s=Replace(s,"%str1%","%str2%")>>LSD.vbs
echo fi.write s>>LSD.vbs
echo fi.close>>LSD.vbs
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('dir /a-d /b %ext%') do (set b=%%~fa&& cscript LSD.vbs !b!)>nul
del LSD.vbs
exit
@echo off
set str1=原字符
set str2=替换为
set ext=*.txt
echo file=wscript.arguments(0)>LSD.vbs
echo set fso=createobject("scripting.filesystemobject")>>LSD.vbs
echo set fil=fso.opentextfile(file)>>LSD.vbs
echo s=fil.readall>>LSD.vbs
echo fil.close>>LSD.vbs
echo set fi=fso.opentextfile(file,2)>>LSD.vbs
echo s=Replace(s,"%str1%","%str2%")>>LSD.vbs
echo fi.write s>>LSD.vbs
echo fi.close>>LSD.vbs
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('dir /a-d /b %ext%') do (set b=%%~fa&& cscript LSD.vbs !b!)>nul
del LSD.vbs
exit
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询