Skip to content

Instantly share code, notes, and snippets.

@bergpb
Last active April 11, 2018 11:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bergpb/93adf2fb1391a32189d865d0dd242181 to your computer and use it in GitHub Desktop.
Save bergpb/93adf2fb1391a32189d865d0dd242181 to your computer and use it in GitHub Desktop.
Convert '.doc' into a '.pdf' file.
# -*- 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))
@bergpb
Copy link
Author

bergpb commented Apr 4, 2018

@a113f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment