Skip to content

Instantly share code, notes, and snippets.

@JosephKJ
Created December 14, 2018 11:11
Show Gist options
  • Save JosephKJ/1e9e3527cb45f8b12480183e0b4fa34c to your computer and use it in GitHub Desktop.
Save JosephKJ/1e9e3527cb45f8b12480183e0b4fa34c to your computer and use it in GitHub Desktop.
Extract images in different folders to single folder
import os
from shutil import copyfile
train_path = '/DATA1/datasets/ILSVRC2012_img_train/imagenet'
destination_path = '/DATA1/datasets/ILSVRC2012_img_train/imagenet_all_images'
i = 0
for path, dir_name, file_names in os.walk(train_path):
i += 1
if len(dir_name) == 0:
for file_name in file_names:
file_src = os.path.join(path, file_name)
file_dest = os.path.join(destination_path, file_name)
copyfile(file_src, file_dest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment