批量重命名_Python

# -*- coding: utf-8 -*-

import os

def renameMethod():
    print('rename...')

    path = raw_input('请输入文件夹路径:')
    print '目标路径是:',path

    fileList = os.listdir(path)
    print '总共',len(fileList),'文件'

    i = 0
    for file in fileList:
        oldPath = os.path.join(path, file)
        newName = 'py_auto_rename_%04ld'%i + '.png'
        newPath = os.path.join(path, newName)

        os.rename(oldPath, newPath)

        i += 1

    print('rename end')

def about():
    print('about:[email protected]')

def main():
    renameMethod()
    
if __name__ == '__main__':
    print('0:开始\n1:关于\n请输入:')

    choose = input()

    if choose == 0:
        renameMethod()
    else:
        about()
else:
    pass

你可能感兴趣的:(批量重命名_Python)