Skip to content

Instantly share code, notes, and snippets.

@alaminopu
Created January 2, 2017 11:19
Show Gist options
  • Save alaminopu/876b09c67ef61df3e1ea693cf31f62c5 to your computer and use it in GitHub Desktop.
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.
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