问题
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