批处理或VBS批量替换指定内容?
一个文本里面有很多网址列表,我想批量替换每行尾部为".co"的,全都都替换为".com"还有每行尾部为4位的,全部替换为".com"例如:http://www.soso....
一个文本里面有很多网址列表,我想批量替换每行尾部为".co" 的,全都都替换为".com"还有每行尾部为4位的,全部替换为".com" 例如: http://www.soso.comn 这样尾部为4位,替换为: http://www.soso.com
展开
展开全部
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set fso = CreateObject("Scripting.FileSystemObject")
Function write_text(file,str)
Set f = fso.OpenTextFile(file, 2 ,True)
f.Write str
f.Close
End Function
Function read(file)
Set f = fso.OpenTextFile(file, 1 ,True)
read= f.ReadAll
f.Close
End Function
s=read("1.txt") '1.txt源文件名
s=Replace(s,".comn","缺消.com")
s=Replace(s,".co",".com")
s=Replace(s,"胡扮仔.comm",".com")
write_text "1.txt",s '1.txt生成裤汪结果文件名
Set fso = CreateObject("Scripting.FileSystemObject")
Function write_text(file,str)
Set f = fso.OpenTextFile(file, 2 ,True)
f.Write str
f.Close
End Function
Function read(file)
Set f = fso.OpenTextFile(file, 1 ,True)
read= f.ReadAll
f.Close
End Function
s=read("1.txt") '1.txt源文件名
s=Replace(s,".comn","缺消.com")
s=Replace(s,".co",".com")
s=Replace(s,"胡扮仔.comm",".com")
write_text "1.txt",s '1.txt生成裤汪结果文件名
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询