0
I’m using Lubuntu 17 and had a folder called images with some files dai was trying to rename these files with this programming 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 to images again the files get mixed up, see:
for example 9 turns 3. How do I solve this?