how to print files info like older and newest also sizes

Viewed 19

hello im trying to get some info in a direcotry and print it into a prettytable im trying to get each value couldnt find a good solution for file dates (oldest and yougest) for now the format of the pretty table is good i just need to store the value in desired variables in the date entry i just need a simple date format example 2019/12/12

import os
import datetime

def ts_to_dt(ts):
  return datetime.datetime.fromtimestamp(ts)

for item in os.scandir():
   print(item.name, item.path, item.stat().st_size, ts_to_dt(item.stat().st_atime))

firstE =
lastE = ts_to_dt(item.stat().st_atime)
totalC
avgMb =
maxMb =
minMb =
medMb =
size6 =
size12 =
customer =
instance =

x = PrettyTable()
x.field_names = ["First Entry", "Last Entry", "Total Count", "Avg Mb size", "Max mb size", "Min mb size", "Med mb size", "size 6 months", "size 1 year", "Customer", "Instance" ]
x.add_row([ (firstE), lastE, totalC, avgMb, maxMb, minMb, medMb, size6, size12, customer, instance])
print(x) ```
0 Answers
Related