Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- #
- import os
- from datetime import datetime
- from tabulate import tabulate
- directorio = "."
- tabla = []
- print(f"Directorio de {os.getcwd()}\n")
- # escaneo el directorio
- for item in os.scandir(directorio):
- info = item.stat()
- ult_modificacion = datetime.utcfromtimestamp(info.st_mtime).strftime("%d/%m/%Y %H:%M")
- if item.is_file():
- tamanio = info.st_size
- tabla.append([ult_modificacion, "", tamanio, item.name])
- elif item.is_dir():
- tabla.append([ult_modificacion, "<DIR>", "", item.name])
- print(tabulate(
- tabla,
- headers = ["Fecha y hora", "Tipo", "Tamaño","Nombre"],
- tablefmt = "plain",
- colalign = ["center", "right", "right", "left"]
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement