I am using lubuntu 17 and had a folder called images with some files of there were trying to rename these files with this program in python:
import os
import re
def repl(match):
dic = {"4": "0", "5": "1", "6": "2", "7": "3", "Q": "4",
"J": "5", "K": "6", "A": "7", "2": "8", "3": "9"}
print(match.group()[0], dic[match.group()[0]])
return "{}.".format(dic[match.group()[0]])
for name in os.listdir("pasta"):
old_file = os.path.join("pasta", name)
new_file = os.path.join("teste", re.sub(
r"[A-Z0-9][.]", repl, name))
os.rename(old_file, new_file)
Now if I rename the test folder for images again the files are changed, see:
for example, 9 turns 3. How do I solve this?