import glob filenames = glob.glob('/home/ftp/pub/praktikum/20150317/dark*.fits.gz') import pyfits for filename in filenames: f = pyfits.open(filename) exptime = f[0].header['EXPTIME'] filt = f[0].header['FILTER'] # aaaaa if abs(exptime - 2) < 1e-3: # if 2 - 1e3 < exptime and exptime < 2 + 1e-3: # print("{0}| {1}s {2}".format(filename[-30:],exptime,filt)) print("{0}".format(filename))