Anomalous backslash in string: '\d'. String constant might be missing an r prefix.
Made directory an mandatory argument
refactor: less identation ifs