Created
January 2, 2017 11:19
-
-
Save alaminopu/876b09c67ef61df3e1ea693cf31f62c5 to your computer and use it in GitHub Desktop.
Copy all files from a directory and its sub-directory to another common directory.
This file contains hidden or 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 | |
| import shutil | |
| src = 'upload'; | |
| dest = 'guitars' | |
| src_files = os.listdir(src) | |
| for path_name in src_files: | |
| full_path = os.path.join(src, path_name) | |
| if (os.path.isdir(full_path)): | |
| files = os.listdir(full_path) | |
| for file_path in files: | |
| full_file_name = os.path.join(full_path, file_path) | |
| shutil.copy(full_file_name, dest) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment