im trying to replace all dots (and accents, but's already done) in filename with underscore except extension dot of course. I saw a lot of solutions but mainly with bash. Cant find for python. Probably I should use regex but dont have much experience here. Below my code:
path2 = 'xx'
dicto = {"ą":"a", 
         "ś":"s",
         "ę":"e",
         "ć":"c",
         "ż":"z",
         "ź":"z",
         "ó":"o",
         "ł":"l",
         "ń":"n"}
def find_replace(string, dictionary):
    for item in string:
        if item in dictionary.keys():
            string = string.replace(item, dictionary[item])
    return string
def change_name(path=path2):
    for root, dirs, files in os.walk(path):
        for filename in files:
            if not filename.startswith('~'):
                os.rename(os.path.join(root,filename), os.path.join(root,find_replace(filename, dicto)))
change_name()
 
     
     
    