Aug-10-2020, 06:22 PM
This is tricky to do as a glob. I'd prefer instead to os.listdir() the files and pass through a regex.
import re import os pattern = re.compile(r"\d{6}.txt$") files = [x for x in os.listdir() if pattern.search(x)] print(files)