I would like to rename files with french letters. I am using glob to browse the files and a function I've found on the Internet to remove the french letters. The supprime_accent seems to work ok. However, it doesn't rename files returned by the glob function.
Does anybody knows what can be the reason? Is it related with glob encoding?
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)