Tag track type by database file names, rather than by the type reported on Reflex Central

This commit is contained in:
2022-12-30 03:30:07 -05:00
parent 60ec331d8d
commit 4b80ca0c4c
+19 -18
View File
@@ -5,6 +5,23 @@ from pathlib import Path
from shutil import move, rmtree
from subprocess import run
def type_sort():
if file.__contains__('_Nat_'):
_type_folder = 'National/'
_type_identifier = '_Nat'
elif file.__contains__('_Sx_'):
_type_folder = 'Supercross/'
_type_identifier = '_Sx'
else:
_type_folder = 'Free Ride/'
_type_identifier = ''
_beta_slot_folder = sorting_dir + _type_folder + file.split('.')[0][-1] + '/' + \
file_details[0] + ' - ' + file_details[1] + '/'
Path(_beta_slot_folder).mkdir(mode=0o700, parents=True, exist_ok=True)
return _beta_slot_folder, _type_identifier
archive_dir = input('archive location (full path): ').rstrip('/') + '/'
sorting_dir = input('target (sorted) directory (full path): ').rstrip('/') + '/'
@@ -24,30 +41,14 @@ for filename in file_list:
for file in sub_files:
if file.endswith('.database') or file.endswith('.level') or file.endswith('.package') or \
file.endswith('.scene'):
beta_slot_folder = sorting_dir + file_details[-1] + '/' + file.split('.')[0][-1] + '/' +\
file_details[0] + ' - ' + file_details[1] + '/'
Path(beta_slot_folder).mkdir(mode=0o700, parents=True, exist_ok=True)
if file_details[-1] == 'National':
type_identifier = '_Nat'
elif file_details[-1] == 'Supercross':
type_identifier = '_Sx'
else:
type_identifier = ''
beta_slot_folder, type_identifier = type_sort()
move(subfolder + '/' + file, beta_slot_folder +
f"Beta{type_identifier}_Track_Slot_{file.split('.')[0][-1]}.dx9.{file.split('.')[-1]}")
files = [f for f in listdir(temp_folder)]
for file in files:
if file.endswith('.database') or file.endswith('.level') or file.endswith('.package') or \
file.endswith('.scene'):
beta_slot_folder = sorting_dir + file_details[-1] + '/' + file.split('.')[0][-1] + '/' + \
file_details[0] + ' - ' + file_details[1] + '/'
Path(beta_slot_folder).mkdir(mode=0o700, parents=True, exist_ok=True)
if file_details[-1] == 'National':
type_identifier = '_Nat'
elif file_details[-1] == 'Supercross':
type_identifier = '_Sx'
else:
type_identifier = ''
beta_slot_folder, type_identifier = type_sort()
move(temp_folder + '/' + file, beta_slot_folder +
f"Beta{type_identifier}_Track_Slot_{file.split('.')[0][-1]}.dx9.{file.split('.')[-1]}")
rmtree(temp_folder)