
# https://www.globalsino.com/ICs/
# Find the smallest file in the direct folder only.

import os

theFolder = r"C:\0Python\TestImages"

files = os.listdir(theFolder)

smallest_file_size = 100000000
smallest_file = ""

print("The file sizes of all files are: (in byte)")
for file in files:
    theFile = os.path.join(theFolder, file)
    if os.path.isfile(theFile):
        size = os.path.getsize(theFile)
        print(size)
        if size < smallest_file_size:
            smallest_file_size = size
            smallest_file = theFile

print("The largest file in the current folder is "+smallest_file+ " and size: "+str(smallest_file_size)+" bytes.")
