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()