-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMergeRuns.py
30 lines (22 loc) · 950 Bytes
/
MergeRuns.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
from argparse import ArgumentParser
from distutils.dir_util import copy_tree
import os, glob
def MergeRuns(indirs, outdir):
if not os.path.exists(outdir):
os.makedirs(outdir)
merged_cnt = 0
for indir in indirs:
available_rundirs = glob.glob(os.path.join(indir, "Master_slice*"))
for cur_rundir in available_rundirs:
cur_sourcedir = cur_rundir
cur_targetdir = os.path.join(outdir, "Master_slice_{}.0".format(merged_cnt))
copy_tree(cur_sourcedir, cur_targetdir)
merged_cnt += 1
if __name__ == "__main__":
if not os.environ["ROOTDIR"]:
raise Exception("Error: 'ROOTDIR' not defined. Please do 'source setup_env.sh'.")
parser = ArgumentParser()
parser.add_argument("--outdir", action = "store", dest = "outdir")
parser.add_argument("--indirs", nargs = '+', action = "store")
args = vars(parser.parse_args())
MergeRuns(**args)