python 从共享文件中自动拷贝指定文件到本地
最基本的功能实现,很多详细细节比如路径树的搜索,访问失败处理,拷贝中途出错处理,本地文件夹是否存在处理等等,这些有时间再处理,先把基本功能实现一下:
import os
sharePath = '\\\\192.168.0.111\\soft'
fileList = os.listdir(sharePath)
for filename in sharePath:
if filename == 'toFindFileName':
print ('have found :'+filename)
srcFilename = sharePat+'\\'+filename
desFilename = 'd:\\ftp\\下载\\'
copyCommand = 'copy %s %s'%(srcFilename, desFilename)
print ('copyCommand'+copyCommand)
if os.system(copyCommand) == 0:
print ('copy successed!')
else:
print ('copy failed!')
break