파이썬
[python] 디렉터리 내에서 원하는 파일 개수만큼 옮기기
Heeyeon Choi
2023. 8. 2. 16:31
728x90
import os
import shutil
path = "/ssd/crack/data/concretecrack/"
file_lst = os.listdir(path)
print(file_lst)
count=0
num = 83124
for file in file_lst:
if(count < num):
dir = '/ssd/crack/data/val/'
shutil.move(path + file, dir + file)
print(file)
count = count + 1
else:
break
- path = 옮길 파일들이 있는 경로
- num = 옮기고 싶은 파일의 개수
- dir = 파일들이 옮겨질 장소
728x90