#!/gapps/python/2.7.11/bin/python import os,sys loc = 'localdir/' Files = [] Runs = [] for d in os.listdir(loc): if d.startswith('run3'): nloc = loc+d+'/' r = d[3:8] for f in os.listdir(nloc): if f.startswith('pi0test_run'): nf = nloc+f Files.append(nf) Runs.append(r) Files.sort() Runs.sort() for r in Runs: if (int(r)>30900) and (int(r)<30990): cmd = 'root -b -q \"checktagger.C('+r+')\"' print cmd os.system(cmd)