-
Notifications
You must be signed in to change notification settings - Fork 1
/
copy_mtx_r.py
42 lines (34 loc) · 1.09 KB
/
copy_mtx_r.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
import argparse
import glob
from locale import getdefaultlocale
from os import pardir, sep
from os.path import isdir, abspath
from os.path import join as path_join
from subprocess import Popen, PIPE
from shutil import copyfile
from app.utils.io import print_process
CONSOLE_ENCODING = getdefaultlocale()[1]
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="copy mtx files recursively"
)
parser.add_argument(
"-s",
"--source_path",
help="path of source directory",
required=True,
)
parser.add_argument(
"-d",
"--destination_path",
help="path of destination directory",
required=True
)
args = parser.parse_args()
source_path = abspath(args.source_path)
destination_path = abspath(args.destination_path)
all_files = glob.glob(path_join(source_path, "**", "*.mtx"), recursive=True)
for file in all_files:
rel_file = abspath(file)[len(source_path):]
print(f"[-] Copy {rel_file}")
copyfile(source_path + rel_file, destination_path + rel_file)