-2

I have a directory which contains multiple directories within it. The sub directories each have jpeg images in them. Can you help me to find a way to extract those images and copy them to a single folder using python.

Thanks in advance

  • 1
    http://stackoverflow.com/a/30255302/4889267 this has 90% of the work involved. Check it out – Alan Kavanagh Jul 16 '16 at 20:26
  • 2
    1. [Find files](http://stackoverflow.com/questions/18394147/recursive-sub-folder-search-and-return-files-in-a-list-python) 2. [Copy files](https://docs.python.org/3/library/shutil.html#shutil.copy2) – Delgan Jul 16 '16 at 20:26

1 Answers1

0

you could do for example :

import glob, os
from shutil import copyfile

os.chdir("yourdirectory")
for file in glob.glob("*.jpeg"):
    copyfile(file, "destinationdirectory/"+file)