批量重命名

# -*- coding:utf-8 -*-
#python 2.7
#XiaoDeng
#批量重命名文件

import os #抓取py当前目录 path=os.getcwd()

for file in os.listdir(path): #使用os.listdir()函数获得指定目录中的内容 if 'apk' in file: if "a_signed_zipalign" in file:#多了一层逻辑,暂时先不管 RenameFile=file.replace("a_signed_zipalign","") print (file ,"---->>" ,RenameFile) #重命名并拼接文件路径 os.rename(os.path.join(path,file),os.path.join(path,RenameFile)) #time.sleep(1) print ("over")

 

posted @ 2016-11-13 17:34  Xiao|Deng  阅读(214)  评论(0编辑  收藏  举报