Skip to content

Instantly share code, notes, and snippets.

@luerhard
Created May 12, 2017 22:58
Show Gist options
  • Save luerhard/0b7c7ccc09b5dfd47202d44423ffd4eb to your computer and use it in GitHub Desktop.
Save luerhard/0b7c7ccc09b5dfd47202d44423ffd4eb to your computer and use it in GitHub Desktop.
Script that converts all .rtf-files in a Folder to .txt on Linux
import subprocess
import os
cwd = os.getcwd()
complete_dir = os.listdir()
rel_docs = [doc for doc in complete_dir if doc.endswith('.rtf')]
for doc in rel_docs:
if doc.find('(') != -1:
doc = "'{}'".format(doc)
print("For ", doc)
subprocess.call('soffice --headless --convert-to txt:Text {}'.format(os.path.join(cwd,doc)), shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment