I would like to rename files with french letters. I use glob to browse files and a function that I found on the Internet to remove French letters. supprime_accentseems to be working fine. However, it does not rename files returned by the glob function.
Does anyone know what the reason is? Is it connected with the globe?
def supprime_accent(ligne):
""" supprime les accents du texte source """
accents = { 'a': ['à', 'ã', 'á', 'â'],
'e': ['é', 'è', 'ê', 'ë'],
'i': ['î', 'ï'],
'u': ['ù', 'ü', 'û'],
'o': ['ô', 'ö'] }
for (char, accented_chars) in accents.iteritems():
for accented_char in accented_chars:
ligne = ligne.replace(accented_char, char)
return ligne
for file_name in glob.glob("attachments/*.jpg"):
print supprime_accent(file_name)
source
share