Python & MS Word: Convert .doc to .docx?
You are working with Linux/ubuntu, you can use LibreOffice’s inbuilt converter.
SYNTAX
lowriter --convert-to docx *.doc
Example
lowriter --convert-to docx testdoc.doc
This will convert all doc files to docx and save in the same folder itself.
Is there any package for converting doc file to docx format using python programming in Azure?
There are few approaches:
- with unoconv:
unoconv -d document --format=docx test.doc
- with lowriter:
lowriter --convert-to docx test.doc
- with soffice:
soffice --headless --convert-to docx test.doc
- with libreoffice:
libreoffice --convert-to docx test.doc
You can run these command directly from your terminal but if you want you can integrated them into python as described here:
#!/usr/bin/env python
import glob
import subprocess
for doc in glob.iglob("*.doc"):
subprocess.call(['soffice', '--headless', '--convert-to', 'docx', doc])
In the example I'm using soffice
but you can now substitute unoconv
, lowriter
or libreoffice
.
Convert .doc files in .docx in windows programatically using Python
Try win32com.client instead of just win32com
import win32com.client
word = win32com.client.Dispatch("Word.application")
Related Topics
Ignore Case in Glob() on Linux
Move and Zoom a Tkinter Canvas with Mouse
Comparing a String to Multiple Items in Python
Single Quotes Vs. Double Quotes in Python
Using Python 32 Bit in 64Bit Platform
Command 'X86_64-Linux-Gnu-Gcc' Failed with Exit Status 1
Get Local Network Interface Addresses Using Only Proc
Calculate Time Difference Between Two Pandas Columns in Hours and Minutes
How to Change a Global Variable from Within a Function
Difference Between Venv, Pyvenv, Pyenv, Virtualenv, Virtualenvwrapper, Pipenv, etc
How to Select a Specific Input Device with Pyaudio
How to Check the Operating System in Python
How to Prompt For User Input and Read Command-Line Arguments
CSS Not Loading Wrong Mime Type Django
How to Modify Lines in a File In-Place
How to Pass a List Variable to Subprocess.Call Command in Python