regex - Python: function to identify all subfolders that match a pattern -
i have written following bit of code find subfolders matching pattern. not have way of checking function finding matches.
i want retrieve folders have name of form "19xx@60xx_npo" xx characters, possibly uppercase.
def findwrongencut(path): pathlist = glob.glob("./%s/19*@60*_npo" %path) print pathlist print len(pathlist)
does function above guarantee folders match "19xx@60xx_npo"
yes, match things not directories , names '19xxxxxx@60xxxxxxxx_npo'. if want match specific number of letters, use ?
each character in glob. if want guarantee directories, throw trailing slash on glob expression:
pathlist = glob.glob("./%s/19??@60??_npo/" % path)
Comments
Post a Comment