import glob import re files=glob.glob("scores\*.*") c=[] for file in files: with open(file, 'r') as current_file: a=current_file.read(12) a=a[7:12] a = [float(i) for i in re.findall(r"[-+]?\d*\.\d*", a)] c.append(a) c[0] w=c.index(max(c)) myfile=files[w] import os print (os.getcwd()+"\\"+ myfile)