直接上代码:
import os
path = os.getcwd()
image_count = 1
file_no = 1
for file in os.listdir(path):
if file.split('.')[-1] == 'JPG' or file.split('.')[-1] == 'jpg':
if image_count % 1000 == 1:
os.mkdir(str(file_no))
file_no+=1
image_count+=1
import os
import shutil
path = os.getcwd()
image_count = 0
for file in os.listdir(path):
if file.split('.')[-1] == 'JPG' or file.split('.')[-1] == 'jpg':
image_path = os.path.join(path,file)
folder_no = int(image_count)/1000+1
folder_path = os.path.join(path,str(folder_no))
shutil.move(image_path,folder_path)
image_count+=1