-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
31 lines (25 loc) · 804 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# genfind.py
#
# A function that generates files that match a given filename pattern
import os
import shutil
import fnmatch
import json
# Set config
with open('config.json') as json_data_file:
data = json.load(json_data_file)
src = data["src"]
dst = data["dst"]
# Uncomment if your directory has an escape character
# src = "source/path"
# dst = "destination/path"
def gen_find(filepat,top):
for path, dirlist, filelist in os.walk(top):
for name in fnmatch.filter(filelist,filepat):
yield os.path.join(path,name)
# You can change *.* to *.xslx if you are looking for xlsx files.
# THis allows you to drill down what you are looking for.
if __name__ == '__main__':
filesToMove = gen_find("*.*",src)
for name in filesToMove:
shutil.copy(name, dst)