使用标题、更改跟踪等在文档之间进行幂等 Powershell 单词搜索/替换

发布于 2024-10-11 07:47:11 字数 673 浏览 2 评论 0原文

我找到了一个 或 两个 指南,用于使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蛮可爱 2024-10-18 07:47:11

要替换 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文