How to get a list of all subdirectories and files along with their size, sorted by size in ascending order?
Below is the code for all the files, but not sorted by size. Please, help.
import os import os.path, time from os.path import join, getsize count=0 for root, dirs, files in os.walk('Test'): for file in list(files): fileaddress = os.path.join(root, file) print("\nName:",fileaddress) print("Time:",time.strftime("%m/%d/%Y %I:%M:%S %p",time.localtime(os.path.getmtime(fileaddress)))) count=count+1 print(count);
source share