Created
June 25, 2016 06:39
-
-
Save mintisan/bc1f95364259c0f23e3db880957a48c9 to your computer and use it in GitHub Desktop.
modify split in file_name
This file contains 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 numpy as np | |
import walkdir as wd | |
file_info_type = np.dtype({ | |
'names': ['dir','name'], | |
'formats':['S100','S100'] | |
}) | |
old_split = '-' | |
new_split = '_' | |
# 0. get all file list | |
files = list(wd.file_paths(wd.filtered_walk(os.getcwd(),depth=1,included_files=['*.csv']))) | |
# 1. split dir & file | |
for x in xrange(0,len(files)): | |
s = '\\' | |
p = unicode(s.join(files[x].split('\\')[:-1]), 'gbk') | |
f = files[x].split('\\')[-1] | |
print p, f | |
old = p + '\\' + f | |
new = p + '\\' + f.replace(old_split, new_split) | |
os.rename(old,new) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment