#pygallery 0.1 gustl 20240401 from os import listdir from natsort import natsorted imageextentions = [".jpg", ".jpeg", ".png", ".gif"] folderpath = "./" print("### pygallery ###") imagenamelist = [] filenamelist = listdir(folderpath) for filename in filenamelist: if any(ext in filename for ext in imageextentions): imagenamelist.append(filename) print("-> found " + str(len(imagenamelist)) + " images") imagenamelist_sorted = natsorted(imagenamelist) galleryfilename = "gallery.html" galleryhtml = "\n\ \n\ \n\ \n\ \n" for imagename in imagenamelist_sorted: galleryhtml += '\n' galleryhtml +="\n\ " galleryfile = open(galleryfilename, "w") galleryfile.write(galleryhtml) galleryfile.close() print("-> wrote " + galleryfilename)