# 冻葱的Python学习笔记02-一个批量重命名的脚本

os.rename(oldName, newName)则显而易见的，是更改文件名字的函数。其中的名字是可以包含路径的。

#Multi-Rename Script
#

import os

extName = input('请输入你想批量重命名的文件扩展名(例如 \'txt\'):')
nameRoot = input('请输入命名前缀:')
nameListAll = os.listdir()
nameList = []

for name in nameListAll:
if name.endswith('.' + extName):
nameList.append(name)
print(name)
input('检查到以上文件，按回车键继续...')

index = 1
for name in nameList:
os.rename(name, nameRoot + '-' + str(index) + '.' + extName)
index += 1

input('已完成，回车键退出...')
os._exit(0)

#
#Code by DCTewi on Apr 21st 2018
#Copyright (c) 2018 dctewi.com

1. 图片看不清的话，可以右键-在新页面打开Orz

2. You really make it seem so easy with your presentation but I find this topic to be
actually something that I think I would never understand.
It seems too complex and very broad for me. I’m looking forward
for your next post, I will try to get the hang of it!