Skip to main content

Convert doc to docx on Windows or macOS directly using Microsoft Word (must be installed).

Project description

doc2docx

PyPI

Convert doc to docx on Windows or macOS directly using Microsoft Word (must be installed).

On Windows, this is implemented via win32com while on macOS this is implemented via JXA (Javascript for Automation, aka AppleScript in JS).

Install

Via brew:

brew install cosmojg/tap/doc2docx

Via pipx:

pipx install doc2docx

Via pip:

pip install doc2docx

CLI

usage: doc2docx [-h] [--keep-active] [--version] input [output]

Example Usage:

Convert single doc file in-place from myfile.doc to myfile.docx:
    doc2docx myfile.doc

Batch convert doc folder in-place. Output docx files will go in the same folder:
    doc2docx myfolder/

Convert single doc file with explicit output filepath:
    doc2docx input.doc output.docx

Convert single doc file and output to a different explicit folder:
    doc2docx input.doc output_dir/

Batch convert doc folder. Output docx files will go to a different explicit folder:
    doc2docx input_dir/ output_dir/

positional arguments:
  input          input file or folder. batch converts entire folder or convert
                 single file
  output         output file or folder

optional arguments:
  -h, --help     show this help message and exit
  --keep-active  prevent closing word after conversion
  --version      display version and exit

Library

from doc2docx import convert

convert("input.doc")
convert("input.doc", "output.docx")
convert("my_doc_folder/")

See CLI docs above (or in doc2docx --help) for all the different invocations. It is the same for the CLI and python library.

Jupyter Notebook

If you are using this in the context of jupyter notebook, you will need ipywidgets for the tqdm progress bar to render properly.

pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension

Acknowledgements

Many thanks to @AlJohri for the excellent docx2pdf upon which this is based!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

doc2docx-0.2.4.tar.gz (5.9 kB view hashes)

Uploaded Source

Built Distribution

doc2docx-0.2.4-py3-none-any.whl (6.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page