第1个回答 2013-05-31
import os
from subprocess import call
os.chdir('/d')
call("E:\test\rebuildShader", shell=True)
call("/usr/bin/python RebuildShaders.py", shell=True)
第2个回答 推荐于2016-04-10
1、首先要遍历文件夹使用os.walk
2、满足条件的文件进行copy,copy到指定目录,这时可以使用很多种方法。个人使用的os.system('copy')
3、文件处理使用自己写的C语言函数,需要同上,很多方法。
使用过程中还有一些简单的正则表达式。
参考代码如下:
import os
import re
import win32api
Pattern=0
def Mypattern(Pfilename):
return len(Pattern.findall(Pfilename))
def VisitDir(path):
global SubNum
for root,Dirs,files in os.walk(path):
for file in files:
if Mypattern(file):
SubNum+=1
print os.path.join(root,file)
filepath=os.path.join(root,file)
filepath=filepath+r' '+r'D:\Xpath\thesaugb.dbz'
print filepath
# os.system ("copy %s %s"%(filepath,filename2))
os.system("D:\Test\NewConsole.exe %s"%filepath)
if __name__=="__main__":
path=r"D:\Pkw"
filename2=r'D:\Test'
RecordText=open(r'D:\Record.txt','r+')
Pattern=re.compile(r'^[gG][fF]\w*.sgs.txt$')
SubNum=0
VisitDir(filename2)
# win32api.ShellExecute(0,'open',r'D:\Xpath\NewConsole.exe',filepath,'',1)
print SubNum