使用标题、更改跟踪等在文档之间进行幂等 Powershell 单词搜索/替换
我找到了一个 或 两个 指南,用于使用 powershell 在多个文档中进行单词搜索和替换。它们可以很好地处理简单的文档。但是,该脚本会忽略页眉和页脚中的文本;如果启用“跟踪更改”,它会替换已替换的文本,如果我在同一文件上多次运行脚本,则会生成新文本的多个副本。
关于如何避免这些不良行为并使该脚本健壮的任何线索?
(转发自 Serverfault)。
I've found one or two guides to doing a word search and replace across multiple documents with powershell. They work well on simple documents. However, the script ignores text in headers and footers; and if "track changes" is enabled, it replaces text which has already been replaced, resulting in multiple copies of the new text if I run the script more than once on the same file.
Any clues as to how I can avoid these undesirable behaviors and make this script robust?
(reposted from Serverfault).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要替换 Word 文档所有部分中的文本,请参阅:
使用宏替换任意位置的文本出现在文档中
For replacing text in all parts of a Word document see:
Using a macro to replace text where ever it appears in a document