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('') print('\n') # print each row for x in files: if x[0] == 'index.html': # skip the index.html file because kinda boring continue x[0] = f'{x[0].replace(".html", "")}' 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''); # finish printing the table print('
CreatedModified
{x[0]}{x[1]}{x[2]}
')