mardi 3 décembre 2019

Find files bigger than 300MB in python?

Hi I have written this code to walk a directory and find files bigger than 300MB however I get a lot of duplicate values and the number of duplicates varies between the files. Please can anyone explain this or improve the code for me?

>>> import os
>>> path = 'C:\\Users\\brentond\\Desktop\\Lower Thames Crossing'
>>> for foldername, subfolders, filenames in os.walk(path):
    for subfolder in subfolders:
        for filename in filenames:
            if os.path.getsize(os.path.join(foldername, filename))>300000000:
                print(foldername + '\\' + filename)

Thanks

Aucun commentaire:

Enregistrer un commentaire