Returns a list of all files in a folder, without subfolders (only files).

def list_files(scan_path, contains=None):
    """
    Returns a list of all files in a folder, without subfolders (only files).
    """
    file_list = []
    path = os.path.abspath(scan_path)
    for f in sorted(os.listdir(path)):
        if contains and f.find(contains) < 0:
            continue
        filepath = os.path.join(path, f)
        if os.path.isfile(filepath):
            file_list.append(filepath)
    return file_list