Failed to find "re.compile('([^\\\\]+)_\\d+.jpg$')" in "/content/drive/

Hey mididou, You need of correct matching characters,
in your case:
pat = r’([\w\s.-]).jpg’
maybe works, but for more information read

Regular Expression HOWTO
https://docs.python.org/3/howto/regex.html#regex-howto