Created
December 14, 2018 11:11
-
-
Save JosephKJ/1e9e3527cb45f8b12480183e0b4fa34c to your computer and use it in GitHub Desktop.
Extract images in different folders to single folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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