반응형
# 파일 크기 + 확장자 복합 필터링
파일 확장자와 크기 조건을 동시에 만족하는 파일만 가져오려면 아래처럼 조합할 수 있습니다.
import os
folder_path = 'C:/Users/username/Documents/myfolder'
filtered_files = [f for f in os.listdir(folder_path)
if f.endswith('.csv') and
os.path.getsize(os.path.join(folder_path, f)) > 50000 and
os.path.isfile(os.path.join(folder_path, f))]
print(filtered_files)
예: 50KB 이상 .csv 파일만 수집 가능
반응형
'python3 selenium > Folder , File' 카테고리의 다른 글
파이썬 Python 파일명 패턴이 숫자 또는 날짜 형식인 파일만 필터링 (0) | 2025.05.05 |
---|---|
파이썬 Python 특정 날짜 이후에 수정된 파일 가져오기 (0) | 2025.05.05 |
파이썬 Python pathlib로 특정 확장자만 필터링 (0) | 2025.05.05 |
파이썬 Python pathlib 사용해 폴더 내 모든 파일 가져오기 (0) | 2025.05.05 |
파이썬 Python 하위폴더 포함 특정 확장자 파일 정렬 (0) | 2025.05.05 |