Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automation: how to automate transforming .doc to .docx?

Tags:

automation

I have a bunch of .doc files in a folder which I need to convert to .docx.

To manually convert the .doc to .docx is pretty simple:

  1. Open .doc in Word 2007
  2. Click on Save As...
  3. Save it as .docx

However, doing this for hundreds of files definitely ain't fun. =p

How would you automate this?

like image 887
sivabudh Avatar asked Mar 08 '10 22:03

sivabudh


1 Answers

There is no need to automate Word, which is rather slow and brittle due to pop-up messages, or to use Microsoft's Office File Converter (ofc.exe), which has an unnecessarily complicated user interface.

The simplest and fastest way would be to install either Office 2007 or download and install the Compatibility Pack from Microsoft (if not already done). Then you can convert from .doc to .docx easily using the following command:

"C:\Program Files\Microsoft Office\Office12\wordconv.exe" -oice -nme <input file> <output file>

where <input file> and <output file> need to be fully qualified path names.

The command can be easily applied to multiple documents using for:

for %F in (*.doc) do "C:\Program Files\Microsoft Office\Office12\wordconv.exe" -oice -nme "%F" "%Fx"
like image 109
Dirk Vollmar Avatar answered Oct 03 '22 00:10

Dirk Vollmar