'Replaces all template strings with the correct value'

@staticmethod
def _format_string(pattern, replace_map):

    result_name = pattern
    for cur_replacement in sorted(replace_map.keys(), reverse=True):
        result_name = result_name.replace(cur_replacement, sanitize_filename(replace_map[cur_replacement]))
        result_name = result_name.replace(cur_replacement.lower(), sanitize_filename(replace_map[cur_replacement].lower()))
    return result_name
