import glob, sys, os, string, io, ROOT, math, commands pandapath=os.environ.get('PANDAPATH') sys.path.append(pandapath+'/macro/tpc/FOPI/python/argparse-1.2.1') sys.path.append(pandapath+'/macro/tpc/FOPI/mberger') import argparse from functions import parseRuns parser=argparse.ArgumentParser(description='hadd all lists fitting pattern') parser.add_argument('pattern',help='the pattern the folders with the files.txt has to macth',type=str) parser.add_argument('path',help='the path to recurse while searching for the folders',type=str) parser.add_argument('--subst',help='substitde string with other string',type=str,nargs=2,default=['','']) args=parser.parse_args() for dirpath in os.walk(args.path): for idir in dirpath: if type(idir)==str: if(idir.find(args.pattern)!=-1): flist="{0}/files.txt".format(idir) if os.path.isfile(flist): command='python FOPI/BatchTools/haddFileList.py {0} Auto'.format(flist) if args.subst[0]!='': command+=' --subst {0} {1}'.format(args.subst[0],args.subst[1]) os.system(command)