-
Notifications
You must be signed in to change notification settings - Fork 1
/
epsToPDF.py
34 lines (26 loc) · 936 Bytes
/
epsToPDF.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
import os
import sys
from Misc import processArguments, sortKey
params = {
'file_ext': 'eps',
'folder_name': '.',
'recursive': 0,
}
processArguments(sys.argv[1:], params)
file_ext = params['file_ext']
folder_name = params['folder_name']
recursive = params['recursive']
if recursive:
src_file_gen = [[os.path.join(dirpath, f) for f in filenames if
f.endswith(file_ext)]
for (dirpath, dirnames, filenames) in os.walk(folder_name, followlinks=True)]
src_files = [item for sublist in src_file_gen for item in sublist]
else:
src_files = [os.path.join(folder_name, f) for f in os.listdir(folder_name)
if os.path.isfile(os.path.join(folder_name, f)) and f.endswith(file_ext)]
src_files.sort(key=sortKey)
n_files = len(src_files)
for _f in src_files:
cmd = 'epstopdf {}'.format(_f)
print(cmd)
os.system(cmd)