Rewrite the whole python to include *.doc and *.docx.
import os
import win32com.client as win32
from docx import Document
def convert_to_pdf(docx_path, pdf_path):
    word = win32.Dispatch("Word.Application")
    doc = word.Documents.Open(docx_path)
    doc.SaveAs(pdf_path, FileFormat=17)
    doc.Close()
    word.Quit()
def docx_to_pdf(directory):
    for filename in os.listdir(directory):
        if filename.endswith(".docx"):
            docx_path = os.path.join(directory, filename)
            pdf_path = os.path.join(directory, filename.replace(".docx", ".pdf"))
            convert_to_pdf(docx_path, pdf_path)
            print(f"Converted '{filename}' to PDF.")
# Provide the directory path where the .docx files are located
directory_path = r'D:\Policy\Job Scope'
# Call the function to convert .docx files to PDF
docx_to_pdf(directory_path)
user