convert this script to gradio:
import os
import glob
import shutil

class color:
    black = '\033[30m'
    red = '\033[31m'
    green = '\033[32m'
    yellow = '\033[33m'
    blue = '\033[34m'
    magenta = '\033[35m'
    cyan = '\033[36m'
    light_gray = '\033[37m'
    gray = '\033[90m'
    bright_red = '\033[91m'
    bright_green = '\033[92m'
    bright_yellow = '\033[93m'
    bright_blue = '\033[94m'
    bright_magenta = '\033[95m'
    bright_cyan = '\033[96m'
    white = '\033[97m'

    reset = '\033[0m'
    bold = '\033[1m'        
    italic = '\033[3m'      
    underline = '\033[4m'  
    reversed = '\033[7m'    

# Default paths (you can change them via commands)
TargetFolder = r"C:\Users\hardy\Documents\School\File Sorter\test"
Log = True

ImagesPath = r"C:\Users\hardy\Pictures\Pictures"
MusicPath = r"C:\Users\hardy\Music\Music"
VideoPath = r"C:\Users\hardy\Videos\Videos"

# Mapping of file extensions to destination folders
extension_mapping = {
    # Images
    'jpg': ImagesPath,
    'jpeg': ImagesPath,
    'png': ImagesPath,
    'dng': ImagesPath,
    'img': ImagesPath,
    'webp': ImagesPath,
    'gif': ImagesPath,
    'tif': ImagesPath,
    # Music
    'mp3': MusicPath,
    'wav': MusicPath,
    'flac': MusicPath,
    'aac': MusicPath,
    # Videos
    'mp4': VideoPath,
    'avi': VideoPath,
    'mkv': VideoPath,
    'mov': VideoPath,
    # Documents
    'pdf': r"C:\Users\hardy\Documents",
    'docx': r"C:\Users\hardy\Documents",
    'xlsx': r"C:\Users\hardy\Documents",
    'pptx': r"C:\Users\hardy\Documents",
    'txt': r"C:\Users\hardy\Documents",
    # Compressed
    'zip': r"C:\Users\hardy\Downloads\Compressed",
    'rar': r"C:\Users\hardy\Downloads\Compressed",
    '7z': r"C:\Users\hardy\Downloads\Compressed",
    # Programming Files
    'py': r"C:\Users\hardy\Documents\Programming",
    'java': r"C:\Users\hardy\Documents\Programming",
    'c': r"C:\Users\hardy\Documents\Programming",
    'cpp': r"C:\Users\hardy\Documents\Programming",
    # Add more if desired
}

def log(text=""):
    if Log:
        print(f"{color.gray}{text}{color.reset}")

def print_banner():
    banner_text = f"""
{color.bright_cyan}{color.bold}
########################################
#                                      #
#          Welcome to File Sorter      #
#                                      #
########################################
{color.reset}
"""
    print(banner_text)

def sort():
    for ext, dest_path in extension_mapping.items():
        typesort(ext, TargetFolder, dest_path)

def typesort(file_extension, folder_path, CopyFolder):
    log(f"INFO: Checking if folder '{folder_path}' exists")
    if not os.path.exists(folder_path):
        print(f"ERROR: The folder {folder_path} does not exist.")
        return

    if not os.path.exists(CopyFolder):
        print(f"ERROR: The destination folder {CopyFolder} does not exist.")
        return

    # Search for all files with the given extension in the folder
    log(f"INFO: Searching for all files ending with '.{file_extension}' in '{folder_path}'")
    search_pattern = os.path.join(folder_path, f'*.{file_extension}')
    files = glob.glob(search_pattern)

    if not files:
        log(f"INFO: No files with the extension .{file_extension} found in {folder_path}.")
        return

    # Move the found files
    for file_path in files:
        try:
            shutil.move(file_path, CopyFolder)
            log(f"INFO: {file_path} moved to {CopyFolder}.")
        except Exception as e:
            print(f"ERROR: Error moving {file_path}: {e}")

def get_files_for_extension(ext, folder_path):
    search_pattern = os.path.join(folder_path, f'*.{ext}')
    files = glob.glob(search_pattern)
    return files

def setpath_command():
    print("Which path do you want to set?")
    print("1. Target Folder")
    print("2. Images Path")
    print("3. Music Path")
    print("4. Video Path")
    choice = input("Enter the number of the path to set: ")
    if choice == '1':
        new_path = input("Enter new Target Folder path: ")
        global TargetFolder
        TargetFolder = new_path
        print(f"Target Folder set to: {TargetFolder}")
    elif choice == '2':
        new_path = input("Enter new Images Path: ")
        global ImagesPath
        ImagesPath = new_path
        print(f"Images Path set to: {ImagesPath}")
        update_extension_destinations(ImagesPath, ['jpg', 'jpeg', 'png', 'dng', 'img', 'webp', 'gif', 'tif'])
    elif choice == '3':
        new_path = input("Enter new Music Path: ")
        global MusicPath
        MusicPath = new_path
        print(f"Music Path set to: {MusicPath}")
        update_extension_destinations(MusicPath, ['mp3', 'wav', 'flac', 'aac'])
    elif choice == '4':
        new_path = input("Enter new Video Path: ")
        global VideoPath
        VideoPath = new_path
        print(f"Video Path set to: {VideoPath}")
        update_extension_destinations(VideoPath, ['mp4', 'avi', 'mkv', 'mov'])
    else:
        print("Invalid choice.")

def update_extension_destinations(new_path, extensions):
    for ext in extensions:
        extension_mapping[ext] = new_path

def showpath_command():
    print("Current Paths:")
    print(f"Target Folder: {TargetFolder}")
    print(f"Images Path: {ImagesPath}")
    print(f"Music Path: {MusicPath}")
    print(f"Video Path: {VideoPath}")

def addext_command():
    ext = input("Enter the file extension (without the dot): ").lower()
    dest = input("Enter the destination folder path: ")
    extension_mapping[ext] = dest
    print(f"Extension '.{ext}' will now be sorted into: {dest}")

def rmext_command():
    ext = input("Enter the file extension to remove (without the dot): ").lower()
    if ext in extension_mapping:
        del extension_mapping[ext]
        print(f"Extension '.{ext}' has been removed from sorting.")
    else:
        print(f"Extension '.{ext}' not found in current mappings.")

def showext_command():
    print("Current File Extension Mappings:")
    for ext, path in extension_mapping.items():
        print(f".{ext} -> {path}")

def togglelog_command():
    global Log
    Log = not Log
    print(f"Logging is now {'enabled' if Log else 'disabled'}.")

def preview_command():
    print("Preview of sorting:")
    for ext, dest_path in extension_mapping.items():
        files_moved = get_files_for_extension(ext, TargetFolder)
        if files_moved:
            print(f"Files with extension '.{ext}' will be moved to '{dest_path}':")
            for file_path in files_moved:
                print(f"  {file_path}")
        else:
            print(f"No files with extension '.{ext}' found in '{TargetFolder}'.")

def save_settings():
    with open("file_sorter_settings.txt", "w") as f:
        f.write(f"TargetFolder={TargetFolder}\n")
        f.write(f"Log={Log}\n")
        f.write(f"ImagesPath={ImagesPath}\n")
        f.write(f"MusicPath={MusicPath}\n")
        f.write(f"VideoPath={VideoPath}\n")
        f.write("Extensions:\n")
        for ext, path in extension_mapping.items():
            f.write(f"{ext}:{path}\n")
    print("Settings saved to 'file_sorter_settings.txt'.")

def load_settings():
    try:
        with open("file_sorter_settings.txt", "r") as f:
            lines = f.readlines()
        global TargetFolder, Log, ImagesPath, MusicPath, VideoPath, extension_mapping
        extension_mapping = {}
        for line in lines:
            if line.startswith("TargetFolder="):
                TargetFolder = line.strip().split("=", 1)[1]
            elif line.startswith("Log="):
                Log = line.strip().split("=", 1)[1] == 'True'
            elif line.startswith("ImagesPath="):
                ImagesPath = line.strip().split("=", 1)[1]
            elif line.startswith("MusicPath="):
                MusicPath = line.strip().split("=", 1)[1]
            elif line.startswith("VideoPath="):
                VideoPath = line.strip().split("=", 1)[1]
            elif line.strip() == "Extensions:":
                continue  # Skip the Extensions line
            else:
                if ':' in line:
                    ext, path = line.strip().split(":", 1)
                    extension_mapping[ext] = path
        print("Settings loaded from 'file_sorter_settings.txt'.")
    except FileNotFoundError:
        print("No saved settings found. Using default settings.")

def save_command():
    save_settings()

def load_command():
    load_settings()

# Load settings at start
load_settings()
print_banner()

# Main loop
while True:
    args = input(">> ").strip().split()
    if not args:
        continue
    command = args[0].lower()
    cmd_args = args[1:]

    if command == 'help':
        print(f"{color.bright_cyan}All commands:")
        print("- help | shows this help message")
        print("- exit | exits the program")
        print("- sort [-y] | sorts the files into their folders (with confirmation unless -y is specified)")
        print("- preview | shows what files will be sorted")
        print("- setpath | sets the target or destination paths")
        print("- showpath | shows the current paths")
        print("- addext | adds a file extension to be sorted to a destination")
        print("- rmext | removes a file extension from sorting")
        print("- showext | shows the current file extension mappings")
        print("- togglelog | toggles logging on/off")
        print("- save | saves current settings")
        print("- load | loads saved settings")
        print(f"{color.reset}")

    elif command == 'exit':
        print("Exiting File Sorter. Goodbye!")
        break

    elif command == 'sort':
        if '-y' in cmd_args:
            sort()
        else:
            confirm = input("Are you sure you want to sort the files? (y/n): ").lower()
            if confirm == 'y':
                sort()
            else:
                print("Sorting cancelled.")

    elif command == 'preview':
        preview_command()

    elif command == 'setpath':
        setpath_command()

    elif command == 'showpath':
        showpath_command()

    elif command == 'addext':
        addext_command()

    elif command == 'rmext':
        rmext_command()

    elif command == 'showext':
        showext_command()

    elif command == 'togglelog':
        togglelog_command()

    elif command == 'save':
        save_command()

    elif command == 'load':
        load_command()

    else:
        print(f"{color.red}Unknown Command! Type 'help' to see the list of available commands.{color.reset}")