-
Notifications
You must be signed in to change notification settings - Fork 0
/
mover.py
46 lines (38 loc) · 1.21 KB
/
mover.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
36
37
38
39
40
41
42
43
44
45
46
import os
import glob
import shutil
import multiprocessing as mp
views=['v1','v2','v3','v4']
years=['2014','2015','2016','2017']
newfolder='movedHDRs'
Ecfolder='hdrs/EC'
# for view in views:
# for year in years:
# for month in range(1,13,1):
# try: os.makedirs(os.path.join(newfolder,view,year,str(month)))
# except OSError:
# pass
# files=glob.glob(Ecfolder+'/'+view+'_'+year+ '_'+ str(month)+ '_*')
# for file in files:
# shutil.move(file,os.path.join(newfolder,view,year,str(month)))
def taskmover(view, year,month):
try:
os.makedirs(os.path.join(newfolder, view, year, str(month)))
except OSError:
pass
files = glob.glob(Ecfolder + '/' + view + '_' + year + '_' + str(month) + '_*')
for file in files:
if not os.path.getsize(file) < 500000:
shutil.move(file, os.path.join(newfolder, view, year, str(month)))
def func(args):
return taskmover(*args)
job_args=[]
pool=mp.Pool(processes=4)
for view in views:
for year in years:
for month in range(1,13,1):
comb=[view,year,month]
job_args.append(comb)
pool.map(func,job_args)
pool.close()
pool.join()