Imagine you want to remove a file in a directory which is Excel, but only if it is the same name as a PDF in the same directory.
Have tried the following:
import os
    #if both excel and pdf, remove excel
    directory = r"C:\Users\Max12\Desktop\xml\git\yourubl\attachments\75090058\Status\Verwerking"
    pdffile = os.path.join(directory, '.pdf')
    excelfile = os.path.join(directory, '.xlsx')
    
    if pdffile == excelfile:
        os.remove(excelfile)
Please help
 
     
     
    