Answers
以前的代码,改改就行了。
Python code
def copyLib():
currdir = os.getcwd()
for root ,subdir,files in os.walk(currdir):
for name in files:
filepos = os.path.join(root, name)
subdir = None
subdir = root.replace(currdir,'')
#print 'sub-',subdir
filename= os.path.join(installDir + subdir, name)
if not os.path.exists(os.path.dirname(filename)):
os.makedirs(os.path.dirname(filename))
if os.path.isdir(filename):
continue
if os.path.isfile(filepos):
print 'file from',filepos,'copy to',filename
shutil.copy(filepos, filename)
if name != "mediaServer.cfg":
os.chmod(filename, 700)
return
Python code
#!/usr/bin/python
#encoding=utf-8
import shutil
import os
import re
src = "A"
des = "B"
patterm = re.compile("_")
list = os.listdir(src)
for file in list:
print(file,end='...')
result = patterm.search(file)
if result is not None:
shutil.copy(os.path.join(src,file),os.path.join(des,file))
print("Moved")
else:
print("Not moved")