import os
filePath = 'E:\\IDM下载\\'
name = os.listdir(filePath)
if __name__ == "__main__":
print(name)
for i in name:
used_name = filePath + i
new_name = filePath + i[0:5] + ".ts" #取名字从左至右第5个
print("文件%s重命名成功,新的文件名为%s" % (used_name, new_name))
#os.rename(used_name, new_name)