File Organization
File Organization
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.
Workflow
-
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.