• 목록
  • 아래로
  • 위로
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나 파워쉘에서 이렇게 하려면 상당히 번거롭다고 알고 있네요 ㅠㅠ

 

 

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, 이동할 폴더)

 

파일의 경우에는 위와 같이 하면 됩니다.

 

작성자
이니스프리 119 Lv. (2%) 3560510/115200000EXP

Make StudyForUs Great Again!

 

CSVpuymXAAAVVpd.jpg

댓글 0

권한이 없습니다.
번호 제목 글쓴이 날짜 조회 수
공지 시스템 점검 작업 완료 안내 10 마스터 마스터 24.09.05.16:25 598
공지 [중요] 호스팅 만료와 관련하여 일부 수칙이 변경됩니다. 4 마스터 마스터 23.01.14.02:23 7426
537 [Python] CGV 예매 관련 크롤링 (개요) 이니스프리 이니스프리 23.08.22.21:10 477
536 [Python Requests] multiple cookies를 다루기 - "There are multiple cookies with name python" 에러 처리 이니스프리 이니스프리 23.08.22.01:40 298
535 [Python] How to send BOLD text with Telegram bot 이니스프리 이니스프리 23.08.10.19:51 243
534 [Python] Downloading Youtube Private Videos with Youtube_dlp - 유튜브 '비공개' 동영상 다운로드 이니스프리 이니스프리 23.06.30.20:05 335
533 [Vultr] 원클릭 NextCloud 설치 시 config.php 위치 이니스프리 이니스프리 23.03.05.10:16 258
532 [Python] zipfile 모듈 한글 파일명 깨짐 현상 해결방법 이니스프리 이니스프리 22.08.03.19:37 905
531 [Python] Zip 파일에서 특정 확장자의 파일들만 특정 폴더에 압축 풀기 이니스프리 이니스프리 22.08.01.19:31 564
530 [Python] PyMuPDF의 사용방법 이니스프리 이니스프리 22.07.28.21:33 547
529 [Python] Poppler 등 설치하지 않고 PDF -> Image 하는 모듈 이니스프리 이니스프리 22.07.28.11:20 252
528 [Python] 문자열을 숫자 크기대로 정렬하기 이니스프리 이니스프리 22.07.21.19:57 610
527 [Matplotlib] X축 눈금 레이블 텍스트를 회전시키는 방법 이니스프리 이니스프리 22.07.18.21:05 224
526 [Telegram] Bot의 inline keyboard 제거 이니스프리 이니스프리 22.07.01.20:35 204
525 [Filepond] 가로로 이미지 나열 이니스프리 이니스프리 22.06.20.21:26 292
524 [Selenium] Page down 이니스프리 이니스프리 22.06.19.12:40 192
523 [Python] Function to save list into a text file line by line 이니스프리 이니스프리 22.06.11.21:33 183
522 [Python] Bypassing Cloudflare's anti-bot page with Cloudscraper module 이니스프리 이니스프리 22.06.10.22:11 240
521 [Python] MP4 움짤을 clip하여 thumbnail 生成하기 이니스프리 이니스프리 22.06.09.08:35 188
520 [Python] MP4 50% 進行된 frame을 JPG thumbnail로 生成 이니스프리 이니스프리 22.06.06.15:15 151
519 [Python] MP4 -> JPG thumbnail 生成 1 이니스프리 이니스프리 22.06.04.16:38 151
518 [Python] Sending SMTP メール(Gmail) - Redmail module 이니스프리 이니스프리 22.06.02.20:38 135