import re


def sanitize_file_name(file_name):
    """
    Sanitize a file name by removing extra spaces, replaces spaces with
    underscores and escapes special characters
    """

    file_name = str(file_name).strip().replace(' ', '_')
    return re.sub(r'(?u)[^-\w.]', '', file_name)