0

I have many word document files in which i need to change few letters which are common in all files. I want to make a Script for replacing the text in all files once. I am using windows machine and R is installed. Suggest me even if you have any other way of doing it. This files are microsoft word document files and stored in one folder. I have code which get data into R list and find and replace the text. But it creates the file with changed format. Please suggest me a better way.

KING BHAI
  • 69
  • 7
  • Did you already try changing the .docx to a .zip and opening it? There is a lot of information contained in there! One of those files should contain the text – Baksteen Apr 12 '18 at 09:32
  • So using zip we can replace the text in a file ? I never done such thing can you provide the link for this. – KING BHAI Apr 12 '18 at 09:38

1 Answers1

1

I think you are asking if a package exists that can deal with MS Word file? Yes. It does. It is on CRAN: https://cran.r-project.org/web/packages/officer/index.html.

Radim
  • 455
  • 2
  • 11
  • I could find body_replace_all_text in this package. But still not able to save the desired changed file. – KING BHAI Apr 12 '18 at 10:05
  • thanks I made it using Officer. But still few documents which are in .doc format did not changed. – KING BHAI Apr 12 '18 at 11:10
  • Glad to know officer worked for your case. To convert doc to docx programmatically from within R (kind of), I would suggest calling the command line via `system2()` as suggested here: https://stackoverflow.com/questions/43214237/how-to-convert-doc-to-docx-file-using-r-code?rq=1 – Radim Apr 13 '18 at 03:41