File Organizer
Organize files and folders with analysis, duplicate detection, and automated cleanup.
Workflow
1. Clarify Scope
Before touching any files, confirm with the user:
- Target directory (Downloads, Documents, Projects, etc.)
- Goal (find duplicates, restructure, archive old files)
- Files/folders to exclude (active projects, sensitive data)
- Aggressiveness (conservative sort vs. comprehensive cleanup)
2. Analyze Current State
ls -la [target_directory]
du -sh [target_directory]/* | sort -rh | head -20
Summarize: total files, file type breakdown, size distribution, obvious issues.
3. Detect Duplicates (When Requested)
# Find exact duplicates by hash
find [directory] -type f -exec md5 {} \; | sort | uniq -d
For each duplicate set, show:
- All file paths with sizes and modification dates
- Recommendation on which to keep (newest or best-named)
CRITICAL: Always ask for confirmation before deleting any file.
4. Propose Organization Plan
Present the plan as a structured summary before executing:
Current: X files across Y folders, Z GB total
Proposed structure:
[Directory tree]
Changes:
- Create: [new folders]
- Move: [file counts per destination]
- Rename: [patterns]
- Delete: [duplicates/trash, with user approval]
Files needing your decision: [list unclear items]
Wait for explicit approval before proceeding.
5. Execute
mkdir -p "path/to/new/folders"
mv "old/path/file.pdf" "new/path/file.pdf"
Rules:
- Never delete without confirmation
- Log all moves for potential undo
- Preserve original modification dates
- Handle filename conflicts (append suffix, never overwrite)
- Stop and ask if anything unexpected occurs
6. Report Results
After completion, provide:
- Files organized count
- Space freed (if duplicates removed)
- New folder structure tree
- Maintenance tips (weekly sort, monthly archive review)
Common Patterns
| Task |
Suggested Structure |
| Downloads cleanup |
Work/, Personal/, Installers/, Archive/, ToSort/ |
| Photo organization |
YYYY/MM-MonthName/ (based on EXIF or mtime) |
| Project restructure |
Active/, Archive/YYYY/, Templates/ |
| Desktop cleanup |
Move everything to Documents/ with proper categorization |
Naming Conventions
- Files:
YYYY-MM-DD-description.ext for dated files
- Folders: lowercase with hyphens (
client-proposals, not Client Proposals)
- Remove download artifacts:
doc-final-v2 (1).pdf to doc.pdf
Error Handling
- If permission denied: inform user which files need elevated permissions
- If disk full during moves: stop, report progress so far, suggest freeing space first
- If filename conflict: append
-1, -2 suffix, never silently overwrite
- If EXIF data unavailable for photos: fall back to file modification date
- If target directory does not exist: create it with
mkdir -p, do not fail silently
1---2name: file-organizer3description: Organizes files and folders by analyzing content, detecting duplicates, and restructuring directories. Use when the user says: 'organize my files', 'clean up downloads', 'find duplicates', 'restructure folder', 'organize photos', 'desktop cleanup', 'sort files', 'archive old projects', 'folder structure'. Handles Downloads cleanup, duplicate detection, project reorganization, and photo sorting. Do NOT use for code refactoring (use senior-fullstack), git operations, or codebase restructuring within a software project.4---56# File Organizer78Organize files and folders with analysis, duplicate detection, and automated cleanup.910## Workflow1112### 1. Clarify Scope1314Before touching any files, confirm with the user:15- Target directory (Downloads, Documents, Projects, etc.)16- Goal (find duplicates, restructure, archive old files)17- Files/folders to exclude (active projects, sensitive data)18- Aggressiveness (conservative sort vs. comprehensive cleanup)1920### 2. Analyze Current State2122```bash23ls -la [target_directory]24du -sh [target_directory]/* | sort -rh | head -2025```2627Summarize: total files, file type breakdown, size distribution, obvious issues.2829<important if="finding duplicate files or cleaning up redundant copies">3031### 3. Detect Duplicates (When Requested)3233```bash34# Find exact duplicates by hash35find [directory] -type f -exec md5 {} \; | sort | uniq -d36```3738For each duplicate set, show:39- All file paths with sizes and modification dates40- Recommendation on which to keep (newest or best-named)4142**CRITICAL: Always ask for confirmation before deleting any file.**4344</important>4546<important if="proposing a file organization plan or restructuring a directory">4748### 4. Propose Organization Plan4950Present the plan as a structured summary before executing:5152```53Current: X files across Y folders, Z GB total54Proposed structure:55 [Directory tree]56Changes:57 - Create: [new folders]58 - Move: [file counts per destination]59 - Rename: [patterns]60 - Delete: [duplicates/trash, with user approval]61Files needing your decision: [list unclear items]62```6364Wait for explicit approval before proceeding.6566</important>6768<important if="executing file moves, renames, or deletions during cleanup">6970### 5. Execute7172```bash73mkdir -p "path/to/new/folders"74mv "old/path/file.pdf" "new/path/file.pdf"75```7677Rules:78- **Never delete without confirmation**79- Log all moves for potential undo80- Preserve original modification dates81- Handle filename conflicts (append suffix, never overwrite)82- Stop and ask if anything unexpected occurs8384</important>8586### 6. Report Results8788After completion, provide:89- Files organized count90- Space freed (if duplicates removed)91- New folder structure tree92- Maintenance tips (weekly sort, monthly archive review)9394<important if="organizing Downloads folder or cleaning up desktop files">9596## Common Patterns9798| Task | Suggested Structure |99|------|-------------------|100| Downloads cleanup | Work/, Personal/, Installers/, Archive/, ToSort/ |101| Photo organization | YYYY/MM-MonthName/ (based on EXIF or mtime) |102| Project restructure | Active/, Archive/YYYY/, Templates/ |103| Desktop cleanup | Move everything to Documents/ with proper categorization |104105</important>106107<important if="renaming files or standardizing file naming conventions">108109## Naming Conventions110111- Files: `YYYY-MM-DD-description.ext` for dated files112- Folders: lowercase with hyphens (`client-proposals`, not `Client Proposals`)113- Remove download artifacts: `doc-final-v2 (1).pdf` to `doc.pdf`114115</important>116117## Error Handling118119- If permission denied: inform user which files need elevated permissions120- If disk full during moves: stop, report progress so far, suggest freeing space first121- If filename conflict: append `-1`, `-2` suffix, never silently overwrite122- If EXIF data unavailable for photos: fall back to file modification date123- If target directory does not exist: create it with `mkdir -p`, do not fail silently