File Organization by seb1n/awesome-ai-agent-skills
npx skills add https://github.com/seb1n/awesome-ai-agent-skills --skill 'File Organization'此技能使 AI 代理能够为杂乱的目录带来秩序。给定一个目标路径,代理会扫描所有文件,使用可配置的规则集对它们进行分类,并将它们移动到结构良好的目录树中。它支持按文件类型、修改日期、项目关联或优先级级别进行整理。高级功能包括通过内容哈希进行重复检测、一致的命名约定、试运行预览以及过时文件的自动归档。
扫描目标目录 递归枚举指定目录中的所有文件。收集每个文件的元数据:名称、扩展名、大小、创建日期、修改日期和内容哈希(SHA-256,为重复检测延迟计算)。默认跳过隐藏文件和系统文件(例如,.DS_Store、Thumbs.db),但允许用户通过配置包含它们。
按规则集分类文件 应用活动的整理策略,为每个文件分配目标文件夹。默认策略使用内置的扩展名映射按文件类型分组(例如,.pdf → documents/、.png → images/、.mp3 → audio/)。替代策略包括:按修改日期分组(、)、按从路径前缀或文件名标签推断出的项目名称分组,或按嵌入在文件名中的优先级标签分组(例如, → )。用户可以提供一个 YAML 或 JSON 格式的自定义规则文件来覆盖或扩展任何策略。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
2025/01/2025/02/URGENT-report.pdfpriority-high/检测和处理重复项 比较所有扫描文件的内容哈希。发现重复项时,将最近修改的副本保留在目标位置,并将较旧的副本移动到 _duplicates/ 暂存文件夹。在永久删除之前,向用户展示重复项的摘要以供审查。可选地,用指向规范副本的符号链接替换重复项,以节省磁盘空间,同时保留路径引用。
应用命名约定 根据配置的约定规范化文件名。选项包括:kebab-case(quarterly-report-2025.pdf)、snake_case(quarterly_report_2025.pdf)或日期前缀(2025-01-15_quarterly-report.pdf)。在请求时,去除特殊字符、压缩空白字符并将 Unicode 音译为 ASCII。保留原始扩展名。记录每次重命名,以便操作可逆。
执行移动计划(或试运行) 在移动任何文件之前,生成一个完整的移动计划,显示每个文件的源路径和目标路径。在试运行模式(首次调用的默认模式)下,显示计划并请求确认。一旦确认,根据需要创建目标目录并以原子方式移动文件。将清单文件(_organization-log.json)写入目标目录的根目录,记录所采取的每个操作,从而实现完全撤销。
归档过时文件 可选地识别在可配置阈值(默认:12 个月)内未被访问或修改的文件。将这些文件移动到 _archive/ 目录,保留整理后的子文件夹结构。如果请求,将归档文件夹压缩为 .tar.gz 或 .zip。通知用户回收的总空间。
将代理指向一个目录并指定整理策略。如果未提供策略,代理默认按文件类型整理。
"Organize my ~/Downloads folder by file type."
"Sort the files in /data/raw-exports by modification date, using YYYY/MM subfolders."
"Organize ~/Projects/acme-app using this config file: .file-org-rules.yaml"
自定义规则文件如下所示:
# .file-org-rules.yaml
strategy: type
naming: kebab-case
date_prefix: true
archive_after_days: 365
type_map:
documents: [pdf, docx, txt, md, csv]
images: [jpg, jpeg, png, gif, svg, webp]
audio: [mp3, wav, flac, aac]
video: [mp4, mov, avi, mkv]
archives: [zip, tar, gz, rar, 7z]
code: [py, js, ts, go, rs, java, c, cpp, h]
data: [json, xml, yaml, yml, toml, sql]
ignore:
- node_modules
- .git
- __pycache__
整理前:
~/Downloads/
├── IMG_4012.jpg
├── IMG_4012 (1).jpg ← 重复项
├── Q3 Financial Report.pdf
├── meeting-notes.txt
├── setup_installer.exe
├── song.mp3
├── profile photo.PNG
├── data_export.csv
├── slides_final_v2.pptx
├── backup.zip
└── vacation vid.mp4
用户输入:
"Organize ~/Downloads by file type. Use kebab-case naming. Detect duplicates."
代理输出(试运行预览):
Scan complete: 11 files found, 1 duplicate detected.
Duplicate: IMG_4012 (1).jpg is identical to IMG_4012.jpg (SHA-256 match)
→ Moving IMG_4012 (1).jpg to _duplicates/
Move plan:
IMG_4012.jpg → images/img-4012.jpg
profile photo.PNG → images/profile-photo.png
Q3 Financial Report.pdf → documents/q3-financial-report.pdf
meeting-notes.txt → documents/meeting-notes.txt
data_export.csv → documents/data-export.csv
slides_final_v2.pptx → presentations/slides-final-v2.pptx
song.mp3 → audio/song.mp3
vacation vid.mp4 → video/vacation-vid.mp4
setup_installer.exe → applications/setup-installer.exe
backup.zip → archives/backup.zip
Confirm? (yes / no / edit plan)
整理后(确认后):
~/Downloads/
├── _duplicates/
│ └── img-4012-1.jpg
├── _organization-log.json
├── applications/
│ └── setup-installer.exe
├── archives/
│ └── backup.zip
├── audio/
│ └── song.mp3
├── documents/
│ ├── data-export.csv
│ ├── meeting-notes.txt
│ └── q3-financial-report.pdf
├── images/
│ ├── img-4012.jpg
│ └── profile-photo.png
├── presentations/
│ └── slides-final-v2.pptx
└── video/
└── vacation-vid.mp4
用户输入:
"Reorganize ~/code/my-api into a standard Go project layout. Move source files, tests, configs, and docs into conventional locations."
代理输出(试运行预览):
Detected project type: Go (found go.mod)
Proposed structure:
cmd/my-api/main.go ← entry point (moved from ./main.go)
internal/handlers/ ← HTTP handlers (moved from ./handlers/)
internal/models/ ← data models (moved from ./models/)
internal/service/ ← business logic (moved from ./service/)
pkg/ ← exported library code (empty — populate later)
configs/config.yaml ← moved from ./config.yaml
docs/api-spec.md ← moved from ./API.md
scripts/migrate.sh ← moved from ./migrate.sh
test/integration/ ← moved from ./integration_tests/
go.mod ← unchanged
go.sum ← unchanged
README.md ← unchanged
7 files moved, 3 directories created, 2 files unchanged.
Import paths in Go files updated automatically.
Confirm? (yes / no / edit plan)
git mv 而不是原始的文件系统移动,以便保留历史记录。如果存在未提交的更改,请警告用户。report.pdf 和 report-1.pdf),而不是静默覆盖。node_modules/、.git/、__pycache__/、vendor/ 和类似的工具管理目录。重新整理这些目录会破坏包管理器。other/。如果文件有 shebang 行(例如,#!/usr/bin/env python3),则从解释器推断类型。每周安装次数
–
仓库
GitHub 星标数
51
首次出现时间
–
安全审计
This skill enables an AI agent to bring order to cluttered directories. Given a target path, the agent scans all files, classifies them using a configurable rule set, and moves them into a well-structured directory tree. It supports organization by file type, modification date, project association, or priority level. Advanced features include duplicate detection via content hashing, consistent naming conventions, dry-run previews, and automated archival of stale files.
Scan the Target Directory Recursively enumerate all files in the specified directory. Collect metadata for each file: name, extension, size, creation date, modification date, and content hash (SHA-256, computed lazily for duplicate detection). Skip hidden files and system files (e.g., .DS_Store, Thumbs.db) by default, but allow the user to include them via configuration.
Classify Files by Rule Set Apply the active organization strategy to assign each file to a destination folder. The default strategy groups by file type using a built-in extension map (e.g., .pdf → documents/, .png → images/, .mp3 → audio/). Alternative strategies include: group by modification date (2025/01/, 2025/02/), group by project name inferred from path prefixes or filename tags, or group by a priority label embedded in the filename (e.g., URGENT-report.pdf → priority-high/). Users can supply a custom rule file in YAML or JSON to override or extend any strategy.
Detect and Handle Duplicates Compare content hashes across all scanned files. When duplicates are found, keep the most recently modified copy in the target location and move older copies to a _duplicates/ staging folder. Present a summary of duplicates to the user for review before permanent deletion. Optionally, replace duplicates with symbolic links to the canonical copy to save disk space while preserving path references.
Apply Naming Conventions Normalize filenames according to the configured convention. Options include: kebab-case (quarterly-report-2025.pdf), snake_case (quarterly_report_2025.pdf), or date-prefixed (2025-01-15_quarterly-report.pdf). Strip special characters, collapse whitespace, and transliterate Unicode to ASCII when requested. Preserve original extensions. Log every rename so the operation is reversible.
Execute the Move Plan (or Dry Run) Before moving any files, generate a complete move plan showing source and destination for every file. In dry-run mode (the default for first invocation), display the plan and ask for confirmation. Once confirmed, create destination directories as needed and move files atomically. Write a manifest file (_organization-log.json) to the root of the target directory recording every action taken, enabling a full undo.
Archive Stale Files Optionally identify files that have not been accessed or modified within a configurable threshold (default: 12 months). Move these files to an _archive/ directory, preserving the organized subfolder structure. Compress the archive folder into a .tar.gz or .zip if requested. Notify the user of the total space reclaimed.
Point the agent at a directory and specify the organization strategy. If no strategy is given, the agent defaults to organizing by file type.
"Organize my ~/Downloads folder by file type."
"Sort the files in /data/raw-exports by modification date, using YYYY/MM subfolders."
"Organize ~/Projects/acme-app using this config file: .file-org-rules.yaml"
A custom rule file looks like this:
# .file-org-rules.yaml
strategy: type
naming: kebab-case
date_prefix: true
archive_after_days: 365
type_map:
documents: [pdf, docx, txt, md, csv]
images: [jpg, jpeg, png, gif, svg, webp]
audio: [mp3, wav, flac, aac]
video: [mp4, mov, avi, mkv]
archives: [zip, tar, gz, rar, 7z]
code: [py, js, ts, go, rs, java, c, cpp, h]
data: [json, xml, yaml, yml, toml, sql]
ignore:
- node_modules
- .git
- __pycache__
Before:
~/Downloads/
├── IMG_4012.jpg
├── IMG_4012 (1).jpg ← duplicate
├── Q3 Financial Report.pdf
├── meeting-notes.txt
├── setup_installer.exe
├── song.mp3
├── profile photo.PNG
├── data_export.csv
├── slides_final_v2.pptx
├── backup.zip
└── vacation vid.mp4
User input:
"Organize ~/Downloads by file type. Use kebab-case naming. Detect duplicates."
Agent output (dry-run preview):
Scan complete: 11 files found, 1 duplicate detected.
Duplicate: IMG_4012 (1).jpg is identical to IMG_4012.jpg (SHA-256 match)
→ Moving IMG_4012 (1).jpg to _duplicates/
Move plan:
IMG_4012.jpg → images/img-4012.jpg
profile photo.PNG → images/profile-photo.png
Q3 Financial Report.pdf → documents/q3-financial-report.pdf
meeting-notes.txt → documents/meeting-notes.txt
data_export.csv → documents/data-export.csv
slides_final_v2.pptx → presentations/slides-final-v2.pptx
song.mp3 → audio/song.mp3
vacation vid.mp4 → video/vacation-vid.mp4
setup_installer.exe → applications/setup-installer.exe
backup.zip → archives/backup.zip
Confirm? (yes / no / edit plan)
After (once confirmed):
~/Downloads/
├── _duplicates/
│ └── img-4012-1.jpg
├── _organization-log.json
├── applications/
│ └── setup-installer.exe
├── archives/
│ └── backup.zip
├── audio/
│ └── song.mp3
├── documents/
│ ├── data-export.csv
│ ├── meeting-notes.txt
│ └── q3-financial-report.pdf
├── images/
│ ├── img-4012.jpg
│ └── profile-photo.png
├── presentations/
│ └── slides-final-v2.pptx
└── video/
└── vacation-vid.mp4
User input:
"Reorganize ~/code/my-api into a standard Go project layout. Move source files, tests, configs, and docs into conventional locations."
Agent output (dry-run preview):
Detected project type: Go (found go.mod)
Proposed structure:
cmd/my-api/main.go ← entry point (moved from ./main.go)
internal/handlers/ ← HTTP handlers (moved from ./handlers/)
internal/models/ ← data models (moved from ./models/)
internal/service/ ← business logic (moved from ./service/)
pkg/ ← exported library code (empty — populate later)
configs/config.yaml ← moved from ./config.yaml
docs/api-spec.md ← moved from ./API.md
scripts/migrate.sh ← moved from ./migrate.sh
test/integration/ ← moved from ./integration_tests/
go.mod ← unchanged
go.sum ← unchanged
README.md ← unchanged
7 files moved, 3 directories created, 2 files unchanged.
Import paths in Go files updated automatically.
Confirm? (yes / no / edit plan)
git mv instead of a raw filesystem move so that history is preserved. Warn the user if uncommitted changes exist.report.pdf and report-1.pdf) rather than overwriting silently.node_modules/, .git/, __pycache__/, vendor/, and similar tool-managed directories by default. Reorganizing these breaks package managers.other/ by default. If the file has a shebang line (e.g., #!/usr/bin/env python3), infer the type from the interpreter.Weekly Installs
–
Repository
GitHub Stars
51
First Seen
–
Security Audits
AI Elements:基于shadcn/ui的AI原生应用组件库,快速构建对话界面
60,400 周安装