-
Notifications
You must be signed in to change notification settings - Fork 0
/
abletonSamplesFinal_ALL_COMMANDLINE.py
63 lines (52 loc) · 1.81 KB
/
abletonSamplesFinal_ALL_COMMANDLINE.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
50
51
52
53
54
55
56
57
58
59
60
61
62
import os
import re
import gzip
import pathlib
import glob
from shutil import copyfile
def search_and_print_results(read_data, extension, f):
search_result = re.findall(f"/\w+.*{extension}", read_data)
if search_result:
search_set = set(search_result)
search_str = str(search_set)
replace_space = search_str.replace("%20", " ")
final_list = replace_space.replace(",", "\n")
f.write(final_list)
else:
f.write(f"No {extension.upper()} files found.\n")
def getAllAbletonFiles(filename, f):
print(f'Processing {filename}')
base = os.path.splitext(filename)[0]
temp_zip_file = copyfile(filename, base + '.zip')
try:
with gzip.open(temp_zip_file, 'rb') as f_in:
read_data = f_in.read().decode('utf-8')
search_and_print_results(read_data, 'wav', f)
search_and_print_results(read_data, 'mp3', f)
search_and_print_results(read_data, 'aiff', f)
search_result_vst = re.findall("\w.*vst", read_data)
if search_result_vst:
for element in search_result_vst:
f.write(element + '\n')
else:
f.write("No VST plugins found.\n")
finally:
os.remove(temp_zip_file)
def main():
my_path = pathlib.Path().resolve()
result = []
output_file = 'allSamples.txt'
print('Searching for .als files...')
for x in os.walk(my_path):
for y in glob.glob(os.path.join(x[0], '*.als')):
result.append(y)
if not result:
print('No .als files found.')
return
print('Going through the projects...')
with open(output_file, 'w') as f:
for onefile in result:
getAllAbletonFiles(onefile, f)
print(f'Results written to {output_file}')
if __name__ == '__main__':
main()