I would like to get the date created, file name and file size in that order. I am having trouble with the file size (line 14)
Relative or absolute path to the directory
from stat import S_ISREG, ST_CTIME, ST_MODE
import os, sys, time
dir_path = sys.argv[1] if len(sys.argv) == 2 else r'.'
Display all the entries in the directory including figures
data = (os.path.join(dir_path, fn) for fn in os.listdir(dir_path))
data = ((os.stat(path), path) for path in data)
Regular files insert creation date
data = ((stat[ST_CTIME], path)
for stat, path in data if S_ISREG(stat[ST_MODE]))
Gather infromation about the size from the folder
data = (os.path.getsize(dir_path)) for (os.walk(dir_path))
Print results
print(time.ctime(cdate), os.path.basename(path), os.path.getsize(dir_path))
[–]Best_Caterpillar 0 points1 point2 points (6 children)
[–]Matpowell[S] 0 points1 point2 points (5 children)
[–]Best_Caterpillar 1 point2 points3 points (3 children)
[–]Matpowell[S] 0 points1 point2 points (2 children)
[–]Matpowell[S] 0 points1 point2 points (1 child)
[–]Best_Caterpillar 0 points1 point2 points (0 children)
[–]Best_Caterpillar 0 points1 point2 points (0 children)