Created
February 12, 2020 04:51
-
-
Save ConradMearns/5ab8c8cdd7d0bec5bf6588ed7b443803 to your computer and use it in GitHub Desktop.
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 os | |
# Get list of files to rename | |
files = os.listdir('.') | |
files = filter(lambda x: x.endswith('pdf'), files) | |
import pdftotext | |
for f in files: | |
fdat = "" | |
with open(f, 'rb') as pf: | |
fdat = pdftotext.PDF(pf) | |
fdat = fdat[0].split('\n')[0].strip().replace(' ', '').replace(':','').replace('/', '') | |
#print(fdat) | |
os.rename(f, fdat+'.pdf') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment