728x90
import os
import shutil
f= open("/ssd/crack/data/train.txt","w+")
path = "/ssd/crack/data/train/"
file_lst = os.listdir(path)
for file in file_lst:
if file.endswith(".jpg"):
f.write(path+file +"\n")
f.close()
- f = open("/ssd/crack/data/train.txt","w+") : train.txt 파일을 쓰기 위해 읽습니다.
- path = "/ssd/crack/data/train/" 불러올 폴더
- if file.endswith(".jpg"): .jpg 로 끝나는 파일이라면,
728x90
'파이썬' 카테고리의 다른 글
[python] 카카오톡 API를 사용하여, 나에게 카카오톡 메시지 보내기 (4) | 2023.10.24 |
---|---|
[AI, python] AI HUB 데이터셋의 어노테이션(Annotation, label)을 darknet format으로 변환하기 (BBOX일 경우) (0) | 2023.08.16 |
[python] txt 파일 읽고 수정하기 (0) | 2023.08.10 |
[python] 디렉터리 내에서 원하는 파일 개수만큼 옮기기 (0) | 2023.08.02 |
[파이썬] 디렉터리마다 파일 n개씩만 다른 폴더로 복사하기 (0) | 2023.04.05 |