import win32api
filelist = win32api.FindFiles('F:/recovery/My Music/*.*')
filelist = [(i[9] if i[9] else i[8]) for i in filelist]
for number, filename in enumerate(filelist):
    os.rename(filaname, '%d.mp3' % number)
Rename invalid filename in XP via Python