Feb-04-2022, 04:36 AM
Greetings!
I need to copy all the directories that do not match the pattern:
8 alphanumeric characters all capital, underscore, and the 4 digits at the end.
Something like this:
ED1234ND_2345
YD1COP1Z_3456
And so on...
I’m having a hell of a time creating regex for it.
Here is what I got:
Any help is appreciated.
Thank you!
I need to copy all the directories that do not match the pattern:
8 alphanumeric characters all capital, underscore, and the 4 digits at the end.
Something like this:
ED1234ND_2345
YD1COP1Z_3456
And so on...
I’m having a hell of a time creating regex for it.
Here is what I got:
import re
from pathlib import Path
tofind = '^[A-Z0-9]{8}_d{4}$'
for ed in Path('C:/01/TLogs/').iterdir() :
if ed.is_dir():
rudir = Path(ed).parts[3]
#print(f" Dir_Name -{type(rudir)}")
if re.findall(tofind,rudir) :
print(f" found -> {rudir}")I think the problem is in the 'underscore' part of the regex.Any help is appreciated.
Thank you!
