parent
c2e2aac13c
commit
4f54a8c602
@ -0,0 +1,27 @@ |
||||
import sys |
||||
import os |
||||
import time |
||||
# Make sure we got a directory |
||||
if len(sys.argv) < 2: |
||||
print("Error: Directory not given!") |
||||
quit() |
||||
# Get path, files, and creation/modification times |
||||
path = sys.argv[1] |
||||
file_filter = sys.argv[2] if len(sys.argv) > 2 else '' |
||||
files = [[x, os.path.getctime(f'{path}/{x}'), os.path.getmtime(f'{path}/{x}')] for x in os.listdir(path) if x.endswith(file_filter)] |
||||
# sort by creation time |
||||
files.sort(key= lambda x: x[1], reverse=True) |
||||
# print start of table(including headers) |
||||
print('<table style="border-spacing: 20px;text-align: left;margin-left: auto;margin-right: auto;">') |
||||
print('<tr>\n<th></th><th>Created</th><th>Modified</th></tr>') |
||||
|
||||
# print each row |
||||
for x in files: |
||||
if x[0] == 'index.html': # skip the index.html file because kinda boring |
||||
continue |
||||
x[0] = f'<a href="{x[0]}">{x[0].replace(".html", "")}</a>' |
||||
x[1] = time.strftime("%b %d %Y", time.strptime(time.ctime(x[1]))) |
||||
x[2] = time.strftime("%b %d %Y", time.strptime(time.ctime(x[2]))) |
||||
print(f'<tr><td>{x[0]}</td><td>{x[1]}</td><td>{x[2]}</td></tr>'); |
||||
# finish printing the table |
||||
print('</table>') |
Loading…
Reference in new issue