#!/usr/bin/python3 import sys, re, os, glob filedir = "/home/wn/www/i21k.de/mudw/" indexfilename = "index.html" headline = "Files" dirindexfile = open(filedir + indexfilename, "w") head1 = ( '\n \n' + headline + '\n \n \n ' ) style_fn = '' head2 = "" body1 = 'Back


' body1 += '
Some files. Maybe useful or not.
' body1 += '' foot = "

You can't avoid chaos.

\n" dirindexfile.write(head1 + style_fn + head2 + body1) for file in os.listdir(filedir): if not re.match("^\.", file) and not file == indexfilename: size = os.lstat(filedir + file).st_size if size > 100000000000: sizestr = str(int(size / 1073741824)) + " GiB" elif size > 100000000: sizestr = str(int(size / 1048576)) + " MiB" elif size > 10000: sizestr = str(int(size / 1024)) + " KiB" else: sizestr = str(size) + " B" line = str('' + str(file) + " "+sizestr+ "") dirindexfile.write(line) dirindexfile.write(foot)