forked from LmeSzinc/text_renderer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch_unzip.py
More file actions
28 lines (24 loc) · 864 Bytes
/
Copy pathbatch_unzip.py
File metadata and controls
28 lines (24 loc) · 864 Bytes
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
import os
from shutil import rmtree
from glob import glob
import argparse
def main(font_dir):
zips = glob(font_dir + '/*.zip')
tmp_dir = 'tmp_zip'
if os.path.exists(tmp_dir):
rmtree(tmp_dir)
for zip_fp in zips:
os.system(f'unzip {zip_fp} -d {tmp_dir}')
font_fps = glob(tmp_dir + '/*/*', recursive=True)
for font_fp in font_fps:
if any(font_fp.lower().endswith(suffix) for suffix in ['ttf', 'ttc', 'otf']):
os.system(f'mv {font_fp} {font_dir}')
break
if os.path.exists(tmp_dir):
rmtree(tmp_dir)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--input_dir', type=str, default='./data/fonts/chn',
help='很多zip文件所在的路径')
args = parser.parse_args()
main(args.input_dir)