import glob sciezka = "/scores/model.iter*.npz.bleu" for file in glob.glob(sciezka): with open(file, 'r') as plik: for line in plik.readlines(): bleu = float(line[line.find("=")+ 1:line.find(",")]) if bleu >0: max = bleu maxi = file plik.close() print ( maxi )