From 03a4107ee123283efa58b7007b7bd1b01856d26e Mon Sep 17 00:00:00 2001 From: Wolfgang Nowak Date: Fri, 28 Jan 2022 14:52:37 +0100 Subject: [PATCH] mkdirindex 1.0.1 Create index.html on directory --- mkdirindex.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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)