1 #! python  
 2 #coding:utf-8  
 3   
 4 ##!/usr/bin/python  
 5 # Filename : fileCp.py  
 6 import sys  
 7 import os    
 8 import shutil   
 9   
10 fileList='filelist.txt'  
11 targetDir='files'  
12   
13 filedir = open(fileList)  
14 line = filedir.readline()  
15 log = open('running.log','w')  
16 while line:  
17         line = line.strip('\n');  #如果从VS的fscanf(fp, "%s\n", buf)生成的list需要使用 line.strip('\r\n')
18         basename =  os.path.basename(line)  
19         exists = os.path.exists(line)  
20         if exists :  
21             print 'copy '+line+' to '+os.getcwd()+'/'+targetDir+'/'+basename  
22             log.write('copy '+line+' to '+os.getcwd()+'/'+targetDir+'/'+basename+'\r\n')  
23             shutil.copy(line,targetDir+'/'+basename)  
24         else:  
25             print line+' not exists'  
26             log.write(line+' not exists'+'\r\n')  
27         line = filedir.readline()  
28 log.close()  

 

相关文章:

  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
  • 2022-12-23
  • 2022-12-23
  • 2018-01-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2023-01-25
  • 2021-07-25
  • 2021-11-21
  • 2022-12-23
  • 2022-01-26
相关资源
相似解决方案