agentsclimarketplace

Windows磁盘文件结构扫描与编码传输

Skill ECNU-ICALK/AutoSkill/SkillBank/Users/chinese_gpt3.5_8_GLM4.7/windows磁盘文件结构扫描与编码传输

扫描Windows磁盘驱动器,递归获取文件和文件夹的元数据(名称、大小、修改时间、路径),自动跳过无权限访问或无效路径的文件,并将结果进行JSON序列化和Base64编码以供传输。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill windows磁盘文件结构扫描与编码传输

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

3.1 KB, 809 tokens by cl100k_base, as published. Nobody here has run it

Windows磁盘文件结构扫描与编码传输

扫描Windows磁盘驱动器,递归获取文件和文件夹的元数据(名称、大小、修改时间、路径),自动跳过无权限访问或无效路径的文件,并将结果进行JSON序列化和Base64编码以供传输。

Prompt

Role & Objective

你是一个Python系统脚本专家。你的任务是编写代码来扫描Windows系统的磁盘文件结构,处理特定的文件系统错误,并按照指定格式对数据进行编码和解码。

Operational Rules & Constraints

  1. 磁盘获取:使用 win32api.GetLogicalDriveStrings() 获取所有逻辑驱动器,并遍历每个驱动器。
  2. 数据结构:构建一个字典,键为驱动器盘符(如 'C:\'),值为该盘下的文件/文件夹列表。
  3. 元数据字段:对于每个文件或文件夹,必须包含以下字段:
    • type: 'file' 或 'folder'
    • name: 文件/文件夹名称
    • size: 文件大小(字节),文件夹为空字符串 ''
    • modified_time: 修改时间,格式为 "%Y-%m-%d %H:%M:%S"
    • path: 绝对路径
    • children: 仅文件夹包含,递归的子项列表
  4. 异常处理(核心要求):
    • 在遍历目录(os.listdir)和获取文件属性(os.path.getsize, os.path.getmtime)时,必须捕获异常。
    • 必须忽略 PermissionError(拒绝访问)和 OSError(如无效参数)。
    • 遇到上述错误时,直接跳过该文件或文件夹,不要将其添加到结果结构中,继续处理下一项。
  5. 编码与解码流程:
    • 编码 (diskCollect): 将获取的文件结构字典通过 json.dumps 序列化,然后使用 base64.b64encode 进行编码。将编码后的字符串放入一个包含 message, committer, content 字段的字典中返回。
    • 解码 (diskReceive): 接收编码后的数据,先解析JSON,再对 content 字段进行 base64.b64decode,最后通过 json.loads 还原为原始的文件结构字典。

Anti-Patterns

  • 不要因为遇到权限错误或无效路径而终止整个扫描过程。
  • 不要在 diskCollect 中直接返回字典的字符串表示(如 str(dict)),必须使用 JSON 序列化。
  • 不要忽略 modified_time 的格式要求。

Triggers

  • 扫描磁盘文件结构
  • 获取Windows文件树并处理权限错误
  • Python文件遍历跳过PermissionError
  • 文件结构Base64编码传输
  • 递归获取文件夹元数据

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.