- 0
- 이니스프리
- 조회 수 4121
1 2 3 4 5 6 7 | import os, shutil for root, subdirs, files in os.walk(검색할 폴더): for d in subdirs: if '찾을 단어' in d: dir_to_move = os.path.join(root, d) shutil.move(dir_to_move, 이동할 폴더) |
폴더 내에서 특정 단어가 들어가는 하위 폴더를 모두 옮기려면 위와 같이 하면 됩니다.
윈도우 CMD나 파워쉘에서 이렇게 하려면 상당히 번거롭다고 알고 있네요 ㅠㅠ
1 2 3 4 5 6 7 | import os, shutil for root, subdirs, files in os.walk(검색할 폴더): for f in files: if '찾을 단어' in f: file_to_move = os.path.join(root, f) shutil.move(file_to_move, 이동할 폴더) |
파일의 경우에는 위와 같이 하면 됩니다.
작성자
댓글 0
권한이 없습니다.