-
Notifications
You must be signed in to change notification settings - Fork 0
/
scan_folders.py
36 lines (27 loc) · 1.01 KB
/
scan_folders.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
32
33
34
35
from getFiles import scanFiles, get_info, get_pickle_data, save_pickle_data
from collections import defaultdict
import os
import logging
from logging.config import fileConfig
fileConfig('logging_config.ini')
logger = logging.getLogger(__name__)
files_found = 0
picklename = "{}.pickle".format("scan_files")
data = get_pickle_data(picklename=picklename)
if not data.get("extension"):
data_ext = defaultdict(list)
data_files = defaultdict(list)
for f in scanFiles('c:\\'):
files_found += 1
filename, file_extension = os.path.splitext(f['file'])
data_files[f['file']].append(f)
data_ext[file_extension].append(f)
logger.info("files scanned:{}".format(files_found))
data = {}
data['extension'] = data_ext
data['files'] = data_files
save_pickle_data(data=data, picklename=picklename)
logger.info("Data Saved:{}".format(picklename))
# display infor about the files...
for k,v in data.get("extension", {}).items():
logger.info("\t{} => {}".format(k, len(v)))