import re
from pathlib import Path
my_dir = r'G:\div_code\foo_folder'
pattern = re.compile(r'^[A-Z0-9]{8}_\d{4}$')
for ed in Path(my_dir).iterdir():
if ed.is_dir():
#print(ed)
# <stem> path component,without it's suffix
if re.search(pattern, ed.stem):
print(ed)
print(ed.stem)
print('-' * 30)