利用Python批量重命名


import os

import sys

path = "H:\python\mysql"

for (path,dirs,files) in os.walk(path):

    for filename in files:

        a = []

        a = filename.split('.')[0]

        b= a.split('-',1)

        newname = b[1] + '-' + b[0] + '.avi'

        print (newname)

        os.rename(path+"\\"+filename , path+"\\"+newname)

你可能感兴趣的:(利用Python批量重命名)