Pythonフォルダのファイル名を一括変更


バッチの変更ファイル名は、同じフォルダの下にあるファイル名をバッチで変更することがよくあります.
import os
import re
import sys

fileList = os.listdir(r"E:\Python    \    ")
#               
for file in fileList :
   print("   :" +file)
#           
currentpath = os.getcwd()
#                    
os.chdir(r"E:\Python    \    ")
#     
num = 1
#           
for fileName in fileList:
    os.rename(fileName, (str(num ) + '.gif' ) )
    #     ,     
    num = num + 1
print("***************************************")
#             
os.chdir(currentpath)
#   
sys.stdin.flush()