#!/scrapy/venvs/amznMailConverter/bin/python import os from datetime import datetime def generate_pdf_list_html(directory, output_file="pdf_list.html"): """Generate an HTML file listing PDF files in the specified directory with the generation timestamp.""" try: # Get a list of PDF files in the directory file_list = [f for f in os.listdir(directory) if f.endswith('.pdf')] file_list.sort(key=lambda a: a.lower()) # Get the current timestamp generation_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") # HTML content with updated styling html_content = f''' PDF Files

Available PDF Files for Download

''' # Write the HTML content to the output file with open(output_file, "w") as file: file.write(html_content) print(f"HTML file generated at: {os.path.abspath(output_file)}") except Exception as e: print(f"An error occurred: {e}") # Usage if __name__ == "__main__": directory = 'amznMailConverter/data' output_file = os.path.join(directory, "pdf_list.html") generate_pdf_list_html(directory, output_file)