-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmcf.py
49 lines (39 loc) · 1.43 KB
/
mcf.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
47
48
49
import os
import subprocess
#
def Batch(args,thisDir,_batchDir, _outDir, _exe):
_files = os.listdir(_batchDir)
_filesChecked = []
if _exe == 'midicsv':
_from = 'mid'
_to = args.ext
else:
_from = args.ext
_to = 'mid'
for c in _files:
if _from in c:
_filesChecked.append(c)
print('checking the {} directory for batching!'.format(_batchDir))
print("{} .{} files found!".format(len(_filesChecked),_from))
#
if args.save_log:
if not os.path.exists('Info Log'):
os.makedirs('Info Log')
#
for m in _filesChecked:
os.chdir(thisDir)
outfd = open("{}/{}.{}".format(_outDir,m.split('.')[0],_to),"w+")
errfd = open("{}/{}.{}".format("Info Log",m,_to),"w+")
print('\nconverting "{}" from .{} to .{}'.format(m,_from,_to))
os.chdir('midicsv-1.1')
subprocess.call([_exe,'-v',thisDir+"/"+_batchDir+"/"+m],stdout=outfd, stderr=errfd)
outfd.close()
errfd.close()
else:
for m in _filesChecked:
os.chdir(thisDir)
outfd = open("{}/{}.{}".format(_outDir,m.split('.')[0],_to),"w+")
print('\nconverting "{}" from .{} to .{}'.format(m,_from,_to))
os.chdir('midicsv-1.1')
subprocess.call([_exe,'-v',thisDir+"/"+_batchDir+"/"+m],stdout=outfd)
outfd.close()