1# credit to Stack Overflow user in the source link
2# requires LibreOffice installed
3
4import os
5import subprocess
6
7for top, dirs, files in os.walk('/my/pdf/folder'):
8 for filename in files:
9 if filename.endswith('.pdf'):
10 abspath = os.path.join(top, filename)
11 subprocess.call('lowriter --invisible --convert-to doc "{}"' # bash/shell syntax
12 .format(abspath), shell=True)
13