代码:
import os


def get_fbx_files_and_write_to_txt(folder_path, output_file_path):
    fbx_files = []
    # 遍历指定文件夹中的所有文件
    for item in os.listdir(folder_path):
        item_path = os.path.join(folder_path, item)
        # 检查是否为文件,并且文件扩展名为.fbx
        if os.path.isfile(item_path) and item.lower().endswith('.fbx'):
            fbx_files.append(item)

    # 将获取到的fbx文件名写入到指定的文本文件中
    with open(output_file_path, 'w', encoding='utf-8') as txt_file:
        for fbx_file in fbx_files:
            txt_file.write(fbx_file + '\n')  # 每个文件名后面添加换行符

    print(f"所有.fbx文件名已写入到 {output_file_path}")


# 指定你想要搜索的文件夹路径
folder_path = r'C:\Users\相晓征\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\pUPA\animations\sport'  # 请替换为你的文件夹路径
# 指定输出文本文件的路径
output_file_path = r'./path_to_your_output_file.txt'  # 请替换为你想要保存的文件路径

get_fbx_files_and_write_to_txt(folder_path, output_file_path)

 

posted on 2024-04-19 13:21  大话人生  阅读(1)  评论(0编辑  收藏  举报