c=0 for (idx, imagePath) in enumerate(imutils.paths.list_images(path)): image = cv2.imread(imagePath) c+=1 file = open("./ppp/"+ c.__str__(), 'w') np.savez_compressed(file, image)