diff --git a/fishyindex.py b/fishyindex.py new file mode 100755 index 0000000..168dc9d --- /dev/null +++ b/fishyindex.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import os +from datetime import datetime + +def mkindex(DIR): + FILE = os.path.join(DIR, 'index.html') + with open(FILE, 'w') as f: + f.write(f'Index of {DIR}

Index of {DIR}


') + f.write(f'

Generated on {datetime.now().strftime("%Y-%m-%d %H:%M:%S")}

') + f.write('') + for f in os.listdir(DIR): + if os.path.isdir(os.path.join(DIR, f)): + f += '/' + timestamp = datetime.fromtimestamp(os.path.getmtime(os.path.join(DIR, f))).strftime('%Y-%m-%d %H:%M:%S') + f = f'' + f.write(f) + f.write('
NameLast Modified
{f}{timestamp}
') + +def index_for_all(DIR): + mkindex(DIR) + for d in os.listdir(DIR): + if os.path.isdir(os.path.join(DIR, d)): + index_for_all(os.path.join(DIR, d)) + +index_for_all(os.getcwd())