python批量文件重命名
摘要:
import osimport rerootdir= r'D:\rizhi\gp-2012-11'pat = re.compile(r'google.*?(\d{8}).*?\.txt')for n in os.listdir(rootdir): match = pat.match(n) if match: oldname = os.path.join(rootdir, n) newname = os.path.join(rootdir, ('gp' + match.group(1) + '.txt')) os.rename(ol 阅读全文