I wrote this piece of code below, but I'm sure it can be done in a more Pythonic way. Only, my knowledge is not that much to be able to figure out a more efficient way.
The DOCX and PDF files are in the same folder.
def compare_text_docx_pdf(path):
for i in range(0, len(os.listdir(path))):
if os.listdir(path)[i].upper().endswith('.PDF') and '.' not in os.listdir(path)[i][:7]:
for j in range(0, len(os.listdir(path))):
if os.listdir(path)[j].upper().endswith('.DOCX'):
if os.listdir(path)[i][:7] == os.listdir(path)[j][:7]:
try:
print('PDF:', os.listdir(path)[i][:7])
print('DOCX:', os.listdir(path)[j][:7])
except Exception as e:
print(e)