File Organizer
Organize files and folders with context-aware analysis, duplicate detection, and automated cleanup.
Instructions
When a user requests file organization help:
Understand the Scope
Ask clarifying questions:
- Which directory needs organization? (Downloads, Documents, entire home folder?)
- What's the main problem? (Can't find things, duplicates, too messy, no structure?)
- Any files or folders to avoid? (Current projects, sensitive data?)
- How aggressively to organize? (Conservative vs. comprehensive cleanup)
Analyze Current State
Review the target directory:
# Get overview of current structure
ls -la [target_directory]
# Check file types and sizes
find [target_directory] -type f -exec file {} \; | head -20
# Identify largest files
du -sh [target_directory]/* | sort -rh | head -20
# Count file types
find [target_directory] -type f | sed 's/.*\.//' | sort | uniq -c | sort -rn
Summarize findings:
- Total files and folders
- File type breakdown
- Size distribution
- Date ranges
- Obvious organization issues
Identify Organization Patterns
Based on the files, determine logical groupings:
By Type:
- Documents (PDFs, DOCX, TXT)
- Images (JPG, PNG, SVG)
- Videos (MP4, MOV)
- Archives (ZIP, TAR, DMG)
- Code/Projects (directories with code)
- Spreadsheets (XLSX, CSV)
- Presentations (PPTX, KEY)
By Purpose:
- Work vs. Personal
- Active vs. Archive
- Project-specific
- Reference materials
- Temporary/scratch files
By Date:
- Current year/month
- Previous years
- Very old (archive candidates)
Find Duplicates
When requested, search for duplicates:
# Find exact duplicates by hash
find [directory] -type f -exec md5 {} \; | sort | uniq -d
# Find files with same name
find [directory] -type f -exec basename {} \; | sort | uniq -d
# Find similar-sized files (macOS)
find [directory] -type f -exec stat -f '%z %N' {} \; | sort -n
For each set of duplicates:
- Show all file paths
- Display sizes and modification dates
- Recommend which to keep (usually newest or best-named)
- Important: Always ask for confirmation before deleting
Propose Organization Plan
Present a clear plan before making changes:
# Organization Plan for [Directory]
## Current State
- X files across Y folders
- [Size] total
- File types: [breakdown]
- Issues: [list problems]
## Proposed Structure
[Directory]/
├── Work/
│ ├── Projects/
│ ├── Documents/
│ └── Archive/
├── Personal/
│ ├── Photos/
│ ├── Documents/
│ └── Media/
└── Downloads/
├── To-Sort/
└── Archive/
## Changes I'll Make
1. **Create new folders**: [list]
2. **Move files**:
- X PDFs → Work/Documents/
- Y images → Personal/Photos/
- Z old files → Archive/
3. **Rename files**: [any renaming patterns]
4. **Delete**: [duplicates or trash files]
## Files Needing Your Decision
- [List any files you're unsure about]
Ready to proceed? (yes/no/modify)
Execute Organization
After approval, organize systematically:
# Create folder structure
mkdir -p "path/to/new/folders"
# Move files with clear logging
mv "old/path/file.pdf" "new/path/file.pdf"
# Rename files with consistent patterns
# Example: "YYYY-MM-DD - Description.ext"
Important Rules:
- Always confirm before deleting anything
- Log all moves for potential undo
- Preserve original modification dates
- Handle filename conflicts gracefully
- Stop and ask if you encounter unexpected situations
Provide Summary and Maintenance Tips
After organizing:
# Organization Complete! ✨
## What Changed
- Created [X] new folders
- Organized [Y] files
- Freed [Z] GB by removing duplicates
- Archived [W] old files
## New Structure
[Show the new folder tree]
## Maintenance Tips
To keep this organized:
1. **Weekly**: Sort new downloads
2. **Monthly**: Review and archive completed projects
3. **Quarterly**: Check for new duplicates
4. **Yearly**: Archive old files
## Quick Commands for You
```bash
# Find files modified this week
find . -type f -mtime -7
# Sort downloads by type
[custom command for their setup]
# Find duplicates
[custom command]
Want to organize another folder?
Grouping Strategies
Based on the files found, determine logical groupings:
By Type: Documents (PDFs, DOCX, TXT), Images (JPG, PNG, SVG), Videos (MP4, MOV), Archives (ZIP, TAR, DMG), Code/Projects, Spreadsheets (XLSX, CSV), Presentations (PPTX, KEY)
By Purpose: Work vs. Personal, Active vs. Archive, Project-specific, Reference materials, Temporary/scratch files
By Date: Current year/month, Previous years, Very old (archive candidates)
1---2name: file-organizer3description: Organize files and folders by analyzing directory contents, finding duplicates, suggesting better structures, and automating cleanup. This skill should be used when the user wants to organize files, clean up a folder (Downloads, Desktop, Documents), find duplicate files, sort files by type or date, restructure project directories, declutter a messy directory, or archive old files.4---56# File Organizer78Organize files and folders with context-aware analysis, duplicate detection, and automated cleanup.910## Instructions1112When a user requests file organization help:13141. **Understand the Scope**15 16 Ask clarifying questions:17 - Which directory needs organization? (Downloads, Documents, entire home folder?)18 - What's the main problem? (Can't find things, duplicates, too messy, no structure?)19 - Any files or folders to avoid? (Current projects, sensitive data?)20 - How aggressively to organize? (Conservative vs. comprehensive cleanup)21222. **Analyze Current State**23 24 Review the target directory:25 ```bash26 # Get overview of current structure27 ls -la [target_directory]28 29 # Check file types and sizes30 find [target_directory] -type f -exec file {} \; | head -2031 32 # Identify largest files33 du -sh [target_directory]/* | sort -rh | head -2034 35 # Count file types36 find [target_directory] -type f | sed 's/.*\.//' | sort | uniq -c | sort -rn37 ```38 39 Summarize findings:40 - Total files and folders41 - File type breakdown42 - Size distribution43 - Date ranges44 - Obvious organization issues45463. **Identify Organization Patterns**47 48 Based on the files, determine logical groupings:49 50 **By Type**:51 - Documents (PDFs, DOCX, TXT)52 - Images (JPG, PNG, SVG)53 - Videos (MP4, MOV)54 - Archives (ZIP, TAR, DMG)55 - Code/Projects (directories with code)56 - Spreadsheets (XLSX, CSV)57 - Presentations (PPTX, KEY)58 59 **By Purpose**:60 - Work vs. Personal61 - Active vs. Archive62 - Project-specific63 - Reference materials64 - Temporary/scratch files65 66 **By Date**:67 - Current year/month68 - Previous years69 - Very old (archive candidates)70714. **Find Duplicates**72 73 When requested, search for duplicates:74 ```bash75 # Find exact duplicates by hash76 find [directory] -type f -exec md5 {} \; | sort | uniq -d7778 # Find files with same name79 find [directory] -type f -exec basename {} \; | sort | uniq -d8081 # Find similar-sized files (macOS)82 find [directory] -type f -exec stat -f '%z %N' {} \; | sort -n83 ```84 85 For each set of duplicates:86 - Show all file paths87 - Display sizes and modification dates88 - Recommend which to keep (usually newest or best-named)89 - **Important**: Always ask for confirmation before deleting90915. **Propose Organization Plan**92 93 Present a clear plan before making changes:94 95 ```markdown96 # Organization Plan for [Directory]97 98 ## Current State99 - X files across Y folders100 - [Size] total101 - File types: [breakdown]102 - Issues: [list problems]103 104 ## Proposed Structure105 106 ```107 [Directory]/108 ├── Work/109 │ ├── Projects/110 │ ├── Documents/111 │ └── Archive/112 ├── Personal/113 │ ├── Photos/114 │ ├── Documents/115 │ └── Media/116 └── Downloads/117 ├── To-Sort/118 └── Archive/119 ```120 121 ## Changes I'll Make122 123 1. **Create new folders**: [list]124 2. **Move files**:125 - X PDFs → Work/Documents/126 - Y images → Personal/Photos/127 - Z old files → Archive/128 3. **Rename files**: [any renaming patterns]129 4. **Delete**: [duplicates or trash files]130 131 ## Files Needing Your Decision132 133 - [List any files you're unsure about]134 135 Ready to proceed? (yes/no/modify)136 ```1371386. **Execute Organization**139 140 After approval, organize systematically:141 142 ```bash143 # Create folder structure144 mkdir -p "path/to/new/folders"145 146 # Move files with clear logging147 mv "old/path/file.pdf" "new/path/file.pdf"148 149 # Rename files with consistent patterns150 # Example: "YYYY-MM-DD - Description.ext"151 ```152 153 **Important Rules**:154 - Always confirm before deleting anything155 - Log all moves for potential undo156 - Preserve original modification dates157 - Handle filename conflicts gracefully158 - Stop and ask if you encounter unexpected situations1591607. **Provide Summary and Maintenance Tips**161 162 After organizing:163 164 ```markdown165 # Organization Complete! ✨166 167 ## What Changed168 169 - Created [X] new folders170 - Organized [Y] files171 - Freed [Z] GB by removing duplicates172 - Archived [W] old files173 174 ## New Structure175 176 [Show the new folder tree]177 178 ## Maintenance Tips179 180 To keep this organized:181 182 1. **Weekly**: Sort new downloads183 2. **Monthly**: Review and archive completed projects184 3. **Quarterly**: Check for new duplicates185 4. **Yearly**: Archive old files186 187 ## Quick Commands for You188 189 ```bash190 # Find files modified this week191 find . -type f -mtime -7192 193 # Sort downloads by type194 [custom command for their setup]195 196 # Find duplicates197 [custom command]198 ```199 200 Want to organize another folder?201 ```202203## Grouping Strategies204205Based on the files found, determine logical groupings:206207**By Type**: Documents (PDFs, DOCX, TXT), Images (JPG, PNG, SVG), Videos (MP4, MOV), Archives (ZIP, TAR, DMG), Code/Projects, Spreadsheets (XLSX, CSV), Presentations (PPTX, KEY)208209**By Purpose**: Work vs. Personal, Active vs. Archive, Project-specific, Reference materials, Temporary/scratch files210211**By Date**: Current year/month, Previous years, Very old (archive candidates)