Task: get the size of all images in machine who have extension
.png
My not working decision:
import os
file_size = []
for root, dirs, files in os.walk("C:\\"):
for file in files:
if file.endswith(".png"):
file_size.append(os.stat(file).st_size)
print(sum(file_size))
Output:
FileNotFoundError: [WinError 2]
Thoughts:
file_size.append(os.stat(file).st_size)
This code can't find the file to get its attribute, how I can correct this?
thanks