import glob sciezka = 'scores/*.npz.bleu' for plik in glob.glob(sciezka): with open(plik, 'r') as f: for linia in f.readlines(): numer = float(linia[linia.find("=") + 1:linia.find(",")]) if numer > 0: max_numer = numer max_numer_plik = plik f.close() print(max_numer_plik)