Created
May 24, 2013 08:13
-
-
Save cnsoft/5642049 to your computer and use it in GitHub Desktop.
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
import os | |
filters = ['.cpp','.h','.py','.hpp','.ipp','.sln','.vcproj','.mak'] | |
filters.extend(['.c','python','Makefile','php']) | |
#filters = ['python'] | |
#filters = ['*'] | |
if os.name == 'posix': | |
FOLDER_FIX = '/' | |
else: | |
FOLDER_FIX = "\\" | |
def checkDirFilter(dir): | |
global filters | |
if filters == ['*']: | |
return True | |
for f in filters: | |
if dir == f or dir.find(f) >0: | |
return True | |
return False | |
def doReplace(filename): | |
f1 = open(filename,'r') | |
f2 = open(filename+'_','w') | |
for line in f1.readlines(): | |
newline = line.replace('\r','\n') | |
f2.write(newline) | |
f2.close() | |
f1.close() | |
os.system('xcopy %s_ %s /y'%(filename,filename)) | |
os.system('del %s_ /F'%(filename)) | |
print 'Process %s ok'%filename | |
def enum_exe(arg,dirname,names): | |
for name in names: | |
file1 = dirname+ FOLDER_FIX +name | |
if not dirname.find('.svn') > 0 and checkDirFilter(file1): | |
if name.find('myReplace.py') < 0 or name.find('_') <0: | |
print 'To process file %s'%file1 | |
if os.path.exists(file1) and os.path.isfile(file1): | |
#if file1.find('python') >0: #only procss that folder | |
doReplace(file1) | |
def convertWin(): | |
os.path.walk(".\\fantasydemo",enum_exe,()) | |
convertWin() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment