티스토리 뷰

반응형

import os

from os.path import exists, isdir


def copy(path, backup_path):

    os.chdir(path)

    

    if not exists(backup_path):

        os.mkdir(backup_path)

    

    file_list = os.listdir(path)

    

    for i in file_list:        

        if isdir(path+i):

            copy(path+i+'/', backup_path+i+'/')

        else:

            with open(path+i,'rb') as a, open(backup_path+i,'wb') as b:

                data = a.read()

                b.write(data)

        

            


path_dir = "C:/Users/GomGuard/Intel/"

path_dir_backup = "C:/Users/GomGuard/backup/"


copy(path_dir,path_dir_backup)

반응형
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함