import os
files=[f for f in os.listdir('C:\Users\Mark\Downloads\Q_29096318')]
#print files
#print max(files)
print max([map(int,x[6:-4].split(".")) for x in files])
It produced the following output:[3, 19]
Note: The two commented lines were there for diagnostic purposes. I needed to ensure that I was retrieving the file names and that the max() function returned incorrect results on string lists.
m = max([map(int,x[6:-4].split(".")) for x in files])
print '.'.join(str(x) for x in m)
import os
def get_max_build_number(folder):
files=[f for f in os.listdir(folder)]
m = max([list(map(int,f[6:-4].split("."))) for f in files])
return '.'.join(str(x) for x in m)
Open in new window
Also I would suggest to include zeros in the build names to make the naming convention a bit clearer.