def test():
    os.chdir('C:/Users/David/Desktop/Test/MyFiles')
files = os.listdir('.')
os.mkdir('C:/Users/David/Desktop/Test/MyFiles2')
pattern = re.compile(regex_txt, re.IGNORECASE)
for x in files:
    with open(x, 'r') as input_file:
        for line in input_file:
            if pattern.search(line):
                shutil.copy(x, 'C:/Users/David/Desktop/Test/MyFiles2')
break
Python: как использовать RegEx в операторе if?