Skip to content

Instantly share code, notes, and snippets.

@fushenghua
Created April 18, 2018 06:49
Show Gist options
  • Save fushenghua/a9db6ab5d7949efa7297dd2c2704eb05 to your computer and use it in GitHub Desktop.
Save fushenghua/a9db6ab5d7949efa7297dd2c2704eb05 to your computer and use it in GitHub Desktop.
rename
# -*- coding: utf-8 -*-
import os
import re
base = '/Users/fushenghua/Documents/Github/'
def rename():
file = open(base + "/name.txt")
while 1:
line = file.readline()
if not line:
break
# print re.findall(r"\[(.+?)\]",line)[0]
name=re.findall(r"\[(.+?)\]",line)[0]
path=re.findall(r"\((.+?)\)",line)[0]
olname=path.split('/')[3]
# print name+path
newname= path.replace(olname,name+'.md')
os.rename(base+path,base+newname)
rename()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment