file-organizer
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 -rnSummarize 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 -nFor 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)