[Solved] How to rename last letter but not the file ending in python [duplicate]


Do something like this

>>> import os
>>> for root, subFolders, files in os.walk('/tmp'):
...   for f in files:
...     if len(f) < 5: continue
...     newf = f[:-5]+f[-5].lower()+f[-4:]
...     print "changing",f,"to",newf
... 

but looks like you want character before extension instead of 5 char? in that case why not just split the extension from filename and rejoin it after lowering the last char

3

solved How to rename last letter but not the file ending in python [duplicate]