Last active
April 11, 2018 11:36
-
-
Save bergpb/93adf2fb1391a32189d865d0dd242181 to your computer and use it in GitHub Desktop.
Convert '.doc' into a '.pdf' file.
This file contains 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
# -*- coding: utf-8 -*- | |
import os | |
#install this dependency | |
#sudo apt-get install unoconv | |
for file in os.listdir(os.getcwd()): | |
#remove all spaces in filename | |
new_file = file.replace(' ', '_') | |
#rename filename | |
os.rename(file, new_file) | |
#if file end with .doc | |
if new_file.endswith('.doc'): | |
os.system('unoconv -f pdf {}'.format(new_file)) | |
print('Success', new_file) | |
else: | |
print('Can\'t convert this file'.format(new_file)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@a113f