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

和自甴很熟 提交于 2020-01-11 10:43:12

问题


We have a .rtf file that needs to be downloaded from a Windows machine, but it contains a lot of pictures in it so it is 2 GB. I would like to download just the text from this file, so it would be ideal if there was an automated script that ran each day on the Windows machine that could convert this file from rtf to txt. Is there a way to do this?


回答1:


You can use unrtf.

unrtf --text /path/to/rtf



回答2:


Depending on your skill level, you can

  • Use Office Automation to build a script in Word to load the RTF and then save as TXT

  • Use .NET to load a copy of Word and then save as TXT

  • Use .NET and regular expressions to filter unnecessary information

  • Use .NET to load the RTF in Internet Explorer and then Save As




回答3:


If you can use 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 application.

Here is a a full example.



来源:https://stackoverflow.com/questions/32977212/is-it-possible-to-change-an-rtf-file-to-txt-file-using-some-sort-of-batch-scri

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!