Python 文件复制程序

import os,shutil
class Copy_file(object):
    def __init__(self,src_file,dst_file,file_type):
        self.src_file = src_file
        self.dst_file = dst_file
        self.file_type = file_type
    def copy(self):
        for file in os.listdir(self.src_file):
            if os.path.splitext(file)[1] == self.file_type:
                for subfolder in os.walk(self.dst_file):
                    print(os.path.join(subfolder[0],file))
                    shutil.copy(os.path.join(self.src_file,file),os.path.join(subfolder[0],file))
src_file = input("Please enter copy source file path:")
dst_file = input("Please enter copy destination file path:")
file_type = input("Please enter copy file type:")
copy_file =  Copy_file(src_file,dst_file,file_type)
copy_file.copy()
exit_key = input("Press any key to exit!")

  

posted @ 2016-11-17 23:14  Vincen_shen  阅读(220)  评论(0)    收藏  举报