是否可以在 Windows 上使用某种批处理脚本将 .rtf 文件更改为 .txt 文件?

Is it possible to change an .rtf file to .txt file using some sort of batch script on Windows?

我们有一个 .rtf 文件需要从 Windows 机器上下载,但它包含很多图片,所以它有 2 GB。我只想从该文件下载文本,因此如果 Windows 机器上每天有一个自动脚本 运行 可以将此文件从 rtf 转换为 txt,那将是理想的选择。有办法吗?

您可以使用 unrtf.

unrtf --text /path/to/rtf

如果可以使用 PowerShell, sure. PowerShell gives you access to the .NET Framework. You can use System.Windows.Forms.RichTextBox to perform the conversion. Your application (or PowerShell code) need not be a Windows Forms 应用程序。

这里是a full example.

根据您的技能水平,您可以

  • 使用 Office Automation 在 Word 中构建脚本以加载 RTF 和 然后另存为TXT

  • 使用 .NET 加载 Word 副本,然后另存为 TXT

  • 使用 .NET 和 regular expressions 过滤不必要的信息

  • 使用 .NET 在 Internet Explorer 中加载 RTF,然后另存为