Get all the files in a subdirectory as a clickable list in an html file

This file let’s you get all the files in a directory and all the sub directories in it as a list into an html page that is clickable.

import os

def myFunc(e):
    return e[1]

lst = []
for r, d, f in os.walk("H:\\classi virtuali"):
    for file in f:
        lst.append([r, file])
lst.sort(key=myFunc)
html = ""
for f in lst:
    html += f"<a href='{f[0]}\\{f[1]}'>{f[1]}</a><br>"
html += "Number of Files: " + str(len(lst))

with open("output.html", "w", encoding="utf-8") as file:
    file.write(html)
os.startfile("output.html")

Video


Subscribe to the newsletter for updates
Tkinter templates
My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts