Python - Get the file properties
Script
import os
import time
filename = "/home/admin/newfile.txt"
filesize1=(os.path.getsize(filename))
getmtime1=(os.path.getmtime(filename))
getctime1=(os.path.getctime(filename))
print("File Properties")
print("---------------")
print("File size : ",filesize1)
print("File modified time : ",time.ctime(getmtime1))
print("File created time : ",time.ctime(getctime1))
print("")
print(os.stat(filename))
OUTPUT
File Properties
---------------
File size : 80
File modified time : Thu Feb 10 05:09:57 2022
File created time : Thu Feb 10 05:09:57 2022
os.stat_result(st_mode=33188, st_ino=3803148, st_dev=64768, st_nlink=1, st_uid=1000, st_gid=1000, st_size=80, st_atime=1644469797, st_mtime=1644469797, st_ctime=1644469797)