Write own regex,glob work many general cases(not for many different corner cases) with a set of predefined pattern eg
Can use eg os.scandir for looping over files,with own regex that match wanted files.
Example:
*.txt
is in regex .*\\.txt\\Z(?ms)
Can use eg os.scandir for looping over files,with own regex that match wanted files.
Example:
import os import re match = re.compile(r'.*\[\d+\].*').match for fn in os.scandir('.'): if match(fn.name): print(fn.name)
Output:Awards Day [1994].mp4
Betula Lake [1983].mp4
Piano Recital [1994].mp4
If i just comment out line 6,the read all files in folder.Output:Awards Day [1994].mp4
Betula Lake [1983].mp4
filename.csv
file_reg.py
foo.txt
Piano Recital [1994].mp4
read_test.py