diff --git a/mkdirindex.py b/mkdirindex.py index 78b7374..4cb49bb 100755 --- a/mkdirindex.py +++ b/mkdirindex.py @@ -3,9 +3,9 @@ import sys, re, os, glob filedir = "/home/wn/www/i21k.de/files/" -indexname = "index.html" -indexmd = "index.md" +indexfilename = "index.html" headline = "Files" +dirindexfile = open(filedir + indexfilename, "w") head1 = ( @@ -21,13 +21,13 @@ head2 = "" body1 = 'Back


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

You can\'t avoid chaos.

\n' +foot = "
You can't avoid chaos.

\n" -print(head1 + style_fn + head2 + body1) +dirindexfile.write(head1 + style_fn + head2 + body1) for file in os.listdir(filedir): - if not re.match("^\.", file) and not file == indexname: + 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" @@ -38,6 +38,7 @@ for file in os.listdir(filedir): else: sizestr = str(size) + " B" - print(""+file+" ", sizestr, "") + line = str('' + str(file) + " "+sizestr+ "") + dirindexfile.write(line) -print(foot) +dirindexfile.write(foot)