需要安装有Microsoft Office,复制粘贴到记事本,另存为xx.bat,编码选ANSI,跟要处理的文件放一起运行
' 2>nul 3>nul&cls&@echo off
'&rem 替换多个word文档/doc文档里的指定内容
'&set #=Any question&set @=WX/&set $=Q&set/az=0x53b7e0b4
'&title %#% +%@%%$%%$% %z%
'&cd /d "%~dp0"
'&dir /a-d/b|findstr "\.doc$ \.docx$"|cscript -nologo -e:vbscript "%~fs0" "需替换的内容" "替换后的内容"
'&echo;%#% +%@%%$%%$% %z%
'&pause&exit
On Error Resume Next
Set fso = CreateObject("scripting.filesystemobject")
Set wd = CreateObject("Word.application")
'wd.Visible = True
Do While WSH.StdIn.AtEndOfStream<>true
line=WSH.StdIn.ReadLine
Set docfile=fso.GetFile(line)
If Left(docfile.shortname, 2) <> "~$" Then
WSH.echo line
Set doc = wd.Documents.Open(docfile.Path,,,,"pwd")
If doc Is Nothing Then
doc.Close
End If
If doc.ProtectionType = -1 Then
doc.Content.Find.Execute WSH.Arguments(0), , , , , , , , , WSH.Arguments(1), 2
End if
doc.Close True
End If
Loop
wd.Quit
WSH.Quit
追问
只出了这个东西,也没有提示替换词是什么,不知道什么意思,请教接着怎么做?
追答按运行后窗口中的提示联系我