import glob os.chdir(path) for file in glob.glob("*.jpg"): print file tmplist=glob.glob('*.[jJ][pP][gG]') # other method: fnmatch and re