Skip to content

Instantly share code, notes, and snippets.

@hovedguy
Created April 9, 2020 15:27
Show Gist options
  • Save hovedguy/263fa40318cca08380d63ce59d72b04e to your computer and use it in GitHub Desktop.
Save hovedguy/263fa40318cca08380d63ce59d72b04e to your computer and use it in GitHub Desktop.
'''
04-09-2020, rev.01
Copy files of particular extension from a directory (nested directories as well) to new directory
'''
import glob
import shutil
main_dir = r'D:\Machine Learning\_Udemy - Complete Tensorflow 2 and Keras Deep Learning Bootcamp'
target_dir = r'C:\Users\suvop\Desktop\target_dir'
files = glob.glob(main_dir + r'\**\*.mp4', recursive=True)
for file in files:
shutil.copy(file, target_dir)
print(f'Number of files copied: {len(files)}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment