Last active
February 16, 2020 13:56
-
-
Save binh-bk/a149d4199c8258f305a6d3377ee398cc to your computer and use it in GitHub Desktop.
find all video files by extensions and collect the files into one 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
# Binh Nguyen, Feb 15, 2020 | |
''' | |
Moving files with movies or images to a designated folder | |
Useful to collect large files (movies) to one places | |
''' | |
import fnmatch | |
import os | |
import shutil | |
movies = ['*.mov', '*.avi', '*.AVI', '*.MOV', '*.mp4', '*.MP4'] | |
rootFolder = '/path/to/root/folder' | |
targetFolder = '/path/to/collection/folder' | |
matches = [] | |
print('Starting...') | |
for root, dirnames, filenames in os.walk(rootFolder): | |
for extensions in movies: | |
for filename in fnmatch.filter(filenames, extensions): | |
_path = os.path.join(root, filename) | |
matches.append(_path) | |
_new_path = os.path.join(targetFolder, filename) | |
shutil.move(_path, _new_path) | |
print('Moving {} to {}'.format(filename, _new_path)) | |
# print(matches) | |
print('Done.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment