Skip to content

Instantly share code, notes, and snippets.

@commonquail
Last active October 4, 2023 12:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save commonquail/6084444fe418b422c286 to your computer and use it in GitHub Desktop.
Save commonquail/6084444fe418b422c286 to your computer and use it in GitHub Desktop.
Recursively convert .doc to .docx

Microsoft Office 2007 and 2010 include a tool that can convert .doc-files to .docx-files from the command line.

This will not get rid of the compatibility-mode message -- that requires opening the file and saving it as a new format -- but it does help with reducing file sizes and cross-platform compatibilities.

The tool is called Wordconv.exe and is located in the root Office folder, e.g. Office14. The tool is unfortunately not documented anywhere, but at least one basic usage is known:

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

Note that the tool creates a new, converted file with the specified name, and does not remove the old file.

With a basic for-loop, the tool can be used sequentially on all files in a directory:

for %f in (C:\docs\*.doc) do "C:\Programmer\Microsoft Office\Office14\Wordconv.exe" -oice -nme "%f" "%fx"

for /? indicates that for may sometimes not support recursive descent, but if it does, all files can be processed recursively with the /R flag:

for /R %f in (C:\docs\*.doc) do "C:\Programmer\Microsoft Office\Office14\Wordconv.exe" -oice -nme "%f" "%fx"

To verify you're processing the correct files, consider running a simple echo first:

for /R %f in (C:\docs\*.doc) do echo "%f"

Note: the *.doc pattern also matches any .docx files.

@awise777
Copy link

awise777 commented Jan 9, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment