Created
May 12, 2017 22:58
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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