首页->【软件工具包使用(SW/Software Tools Usage)】

4 1

##:: ===============================
##:: OpenRight@Otham.Shi,ShangHai,China
##:: FUNCTION: copy the files By the fileList   
##:: PYNAME : copy the files
##:: RELEASE Date : 09/5/18
##:: Create            :Winyoo_Shiy
##:: Tool:PyIDE(3.7.0)
##:: Add_function  : to decrease the time, copy the files by abstract path
##::                        to decrease the operation  of del txt file , use the binlList.tmp
##:: ===============================

##FileList文件格式如图所示

图片.png

import re
import os,sys
import shutil
print('Now,file operation tst')
fileList_path="C:\\Users\\Winyoo\\Desktop\\tst\\FileList.txt"
src_path="C:\\Users\\Winyoo\\Desktop\\srcfolder"
dbg_path="C:\\Users\\Winyoo\\Desktop\\tst\\binlList.tmp"
dst_path="C:\\Users\\Winyoo\\Desktop\\dst"
ftmp=open(dbg_path,'w')
try:
    f=open(fileList_path,'r')
    binlpath=f.readlines()
    print(binlpath)
finally:
    if f:
          f.close()
#repath=re.compile(r'[\t\n]')
for i in binlpath:
      #print(i)
      abspath=re.split(r'[\t\.\n]+',i)
      AbsSrcPath=src_path+abspath[2]+'\\'+abspath[0]+'.'+abspath[1]
      AbsDstPath=dst_path+'\\'+abspath[0]+'.'+abspath[1]
      shutil.copy2(AbsSrcPath,dst_path)
      #os.close(fidDst)
      strtmp=AbsSrcPath+'\n'
      ftmp.write(strtmp)   
f.close()
ftmp.close()
#end of files


楼主可见

  1. shwnyoo 1#

    ***此内容已隐藏,只有楼主可见***