Last active
July 10, 2018 16:21
-
-
Save driscollis/0bee792e7a35bb3fbfd4e51e0e290d1b to your computer and use it in GitHub Desktop.
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
import os | |
import shutil | |
def move_file_type_v2(path, ftype, excludes): | |
matches = glob.glob('{}/**/*{}'.format(path, ftype), recursive=True) | |
for match in matches: | |
dirname, filename = os.path.dirname(match), os.path.basename(match) | |
if dirname not in excludes: | |
proj_dir = os.path.join(dirname, 'ProjectData') | |
if os.path.exists(proj_dir): | |
shutil.move(match, os.path.join(proj_dir, filename)) | |
if __name__ == '__main__': | |
path = '/home/mdriscoll/py/test/' | |
file_type = 'bmp' | |
excludes = [r'C:\Project\RandomFolder\Folder123'] | |
move_file_type_v2(path, file_type, excludes=excludes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment