from glob import glob import shutil import os rar_file = glob(f"{os.path.join(rls.ContentPath, '')}*rar") if rar_file: # Now verify that unrar is installed unrar_sys_package = '/usr/bin/unrar' if os.path.isfile(unrar_sys_package): console.print("Found rar files, extracting the files now", style="bold red") # run the system package unrar and save the extracted file to its parent dir subprocess.run([unrar_sys_package, 'e', rar_file[0], '-idq', rls.ContentPath])