使用python重命名指定目录文件
1. [文件] 指定目录文件重命名 ~ 715B
#Copyright 2012 wuyuangui.#www.iplaypy.com python教程import ospath = 'F:\Python\open project\SGI\SGI_STL'
paths = path.replace('\\', '//')
paths = paths + '//'
print paths
files = os.listdir(paths)
for i in files:#print(i)pat = Nonepat = paths + str(i)if os.path.isdir(pat):passelif os.path.isfile(pat):if not str(pat).endswith('.h'):list = pat.split('//')patt = list[list.__len__() - 1] + '.h'print(str(i) + str(patt))os.rename(pat, str(pat + patt))#os.rename(str(pat + patt), pat)print('regfile:' + pat)else:pass