- 0
- 이니스프리
- 조회 수 803
shutil.copy2를 이용한 간단한 백업 스크립트에요.
overwrite가 잘 되는 것을 확인했어요 :)
주의 : 서브 디렉토리는 포함하지 않습니다.
import os, shutil
source_dir = '소스 디렉토리'
target_dir = '타겟 디렉토리'
count = 0
for basename in os.listdir(source_dir):
if basename.endswith('.확장자'):
pathname = os.path.join(source_dir, basename)
if os.path.isfile(pathname):
print(pathname)
shutil.copy2(pathname, target_dir)
count += 1
print(count)
작성자
댓글 0
권한이 없습니다.




