Jacklovely

导航

 
 1 import os
 2 import re
 3 import shutil
 4 pathJiaoBen = r'C:\Users\jjw\Desktop\601_英语沪教版九年级下册' #脚本
 5 pathRtf = r'D:\XiZhi\ContentSourceSVN\课文\初三年级下册\英语\601_英语沪教版九年级下册' #课文rtf
 6 #C:\Users\jjw\Desktop\601_英语沪教版九年级下册\1_Unit1 Great exploration\1_class_1\1_预习\3_课文朗读
 7 
 8 #for root1, dirs1, files1 in os.walk(path1):    #三个参数:分别返回1.父目录 2.所有文件夹名字(不含路径) 3.所有文件名字
 9 for rootRtf, dirRtf, filesRtf in os.walk(pathRtf):
10     for fileRtf in filesRtf:
11         numUnit,numClass,other = fileRtf.split('-',2)
12         rtf = os.path.join(rootRtf,fileRtf)
13         #print (rtf)
14         #print(numUnit+'..'+numClass)
15         pathLangDu = r'\\.*年级.*\\'+numUnit +r'_.*\\'+numClass+r'.*\d\\1_预习\\3_课文朗读$'
16         #print(pathLangDu)
17         for rootJiaoBen, dirJiaoBen, filesJiaoBen in os.walk(pathJiaoBen):
18             
19             if re.findall(pathLangDu,rootJiaoBen):
20                 #print(rootJiaoBen)
21                 shutil.copy(rtf,rootJiaoBen+'\\' + '课文.rtf')
22             '''else:
23                 print("未找到")'''
24         

r''要用单引号,r=regular,使引号里的\不用转意。

 

posted on 2016-05-16 19:02  Jacklovely  阅读(386)  评论(0编辑  收藏  举报