Given a random length of filepath, how to regex for something in the middle:
name = 'path/to/../../foo/file.py'
something like this:
In [2]: name.startswith('.*/foo/')
Out[2]: False
Given a random length of filepath, how to regex for something in the middle:
name = 'path/to/../../foo/file.py'
something like this:
In [2]: name.startswith('.*/foo/')
Out[2]: False
Instead of using re
Use glob
as the way to do it.
import glob
for filename in glob.iglob('C:\Users\Desktop\**\Start\c*'):
print(filename)
output
C:\Users\Desktop\screenshoots\Start\cmr(1).PNG
C:\Users\Desktop\screenshoots\Start\cmr(2).PNG
C:\Users\Desktop\screenshoots\Start\cmr(3).PNG