import os input = '' for i in xrange(691,700): input+=' ship.10.0.Genie-TGeant_n%s.root'%i os.system('hadd ship.10.0.Genie-TGeant4_n691.root' + input)