Created
April 18, 2018 06:49
-
-
Save fushenghua/a9db6ab5d7949efa7297dd2c2704eb05 to your computer and use it in GitHub Desktop.
rename
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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