From a19389ed1d92b6624591550fd381050e0725b83d Mon Sep 17 00:00:00 2001 From: Wolfgang Nowak Date: Fri, 7 Jan 2022 14:18:46 +0100 Subject: [PATCH] mkdirindex 1.0.0 Create index.html on directory --- mkdirindex.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 mkdirindex.py diff --git a/mkdirindex.py b/mkdirindex.py new file mode 100755 index 0000000..78b7374 --- /dev/null +++ b/mkdirindex.py @@ -0,0 +1,43 @@ +#!/usr/bin/python3 + +import sys, re, os, glob + +filedir = "/home/wn/www/i21k.de/files/" +indexname = "index.html" +indexmd = "index.md" +headline = "Files" + + +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' + + +print(head1 + style_fn + head2 + body1) + +for file in os.listdir(filedir): + if not re.match("^\.", file) and not file == indexname: + 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" + + print(""+file+" ", sizestr, "") + +print(foot)