I have a list of directories named by date MMDDYYYY (11222013). I'm ultimately trying to delete all directories from the year 2013. I believe my regex should be looking for 6 digits [0-9]. I've tried breaking the code into multiple variables but have had no luck.
I suspect I'm not escaping the regex correctly. I keep running into this error:
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:/U sers/USER/Desktop/test/\d{6}13'
I've tried printing my output and I get this path:
C:/Users/USER/Desktop/test/\d{6}13
My code:
import os
import shutil
import re
StrDir = 'C:/Users/USER/Desktop/test/'
Regex = r"\d{6}" + '13'
print (StrDir + Regex)
shutil.rmtree (StrDir + Regex)