오픈소스의 일상

Python 하위디렉토리 특정파일 추출 본문

오픈소스/PYQGIS

Python 하위디렉토리 특정파일 추출

실버카미 2024. 9. 21. 12:54
import os

# 탐색할 디렉토리 지정
directory = "/path/to/directory"

# os.walk()를 사용하여 특정 확장자 파일만 탐색
for root, dirs, files in os.walk(directory):
    for file in files:
        if file.endswith(".txt"):  # .txt 파일만 필터링
            file_path = os.path.join(root, file)
            print(file_path)
728x90

'오픈소스 > PYQGIS' 카테고리의 다른 글

Python QT-TableWidget 초기화  (0) 2024.09.22
[PYQGIS] Feature 검색방법  (0) 2023.09.12
[PYQGIS] 원하는 Shape 파일을 내려받기  (0) 2023.09.12
[Python] Array 중복제거  (0) 2023.09.08